Sub DirectFormat()
Dim para As Paragraph
Dim fnt As Font
Dim pfmt As ParagraphFormat
For Each para In ActiveDocument.Paragraphs
With para
If .Style <> ActiveDocument.Styles("Normal") Then
Set fnt = .Style.Font
Set pfmt = .Style.ParagraphFormat
.Style = ActiveDocument.Styles("Normal")
.Range.Font = fnt
.Range.ParagraphFormat = pfmt
End If
End With
Next
End Sub
Sub DirectFormat()
Dim para As Paragraph
Dim fnt As Font
Dim pfmt As ParagraphFormat
For Each para In ActiveDocument.Paragraphs
With para
If .Style <> ActiveDocument.Styles("Normal") Then
Set fnt = .Style.Font
Set pfmt = .Style.ParagraphFormat
.Style = ActiveDocument.Styles("Normal")
.Range.Font = fnt
.Range.ParagraphFormat = pfmt
End If
End With
Next
End Sub
需要注意的是,如果你同時(shí)打開了多份 Word 文檔,那么在上述 VBA 編輯器的左側(cè),也會(huì)出現(xiàn)多個(gè)文檔的選項(xiàng)。這種場(chǎng)合,請(qǐng)保證選中了 Project(需要去除樣式的文檔)-Microsoft Word Objects-ThisDocument 并使其高亮,然后再在右側(cè)粘貼并執(zhí)行代碼。