2015-06-20 49 views
0

我想编写一个宏以从文档中除去标题以外的所有样式。
我有这个宏,删除所有样式:清除除标题以外的所有样式

Sub clearstyle() 
    ActiveDocument.Select 
    Selection.ClearFormatting 
end Sub 

我怎样才能改善这种只保留标题风格?

回答

1

像这样的东西应该工作:

For Each p In ActiveDocument.Paragraphs 
    If Left(p.Style, 7) <> "Heading" Then 
    p.Range.Select 
    Selection.ClearFormatting 
    End If 
Next 
+0

哇,真棒。非常感谢@Ansgar Wiechers :) –