Word,VBA:以编程方式检查范围内的某些样式

时间:2015-02-11 10:17:47

标签: vba ms-word

我有一个范围。在这个范围内是一些文字。我现在可以用vba检测某个样式 - 比方说标题1 - 是否在这个范围内使用?

1 个答案:

答案 0 :(得分:0)

使用Selection.Find方法

可以实现
mySelection.Find.ClearFormatting
mySelection.Find.Style = ActiveDocument.Styles("Heading 1")
With mySelection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .CorrectHangulEndings = False
        .HanjaPhoneticHangul = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .MatchFuzzy = False
End With
mySelection.Find.Execute