Sub SelectLevel1Headings() Dim doc As Document Set doc = ActiveDocument

Dim rng As Range
Set rng = doc.Range

With rng.Find
    .ClearFormatting
    .Style = ActiveDocument.Styles("Heading 1")
    .Text = ""
    .Format = True
    .Forward = True
    .Execute
End With

If rng.Find.Found = True Then
    rng.Select
Else
    MsgBox "No level 1 headings found."
End If

End Sub

帮我写一段VBA代码选中WORD中的大纲级别为1级的标题

原文地址: https://www.cveoy.top/t/topic/EpC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录