When using range.find to find bold text it won't find if the entire selection is bold!

前端 未结 1 319
礼貌的吻别
礼貌的吻别 2020-12-21 15:52

I\'m trying to extract bold text using the range.find method and all is peachy except if the entire range is actually bold (not likely to happen much, it\'s more of an edge

相关标签:
1条回答
  • 2020-12-21 16:56

    This should find any bold text:

    Sub SearchBoldText()
        Dim rng As Range
        Set rng = ThisDocument.Range(0, 0)
        With rng.Find
            .ClearFormatting
            .Format = True
            .Font.Bold = True
            While .Execute
                rng.Select
                rng.Collapse direction:=wdCollapseEnd
            Wend
        End With
        Set rng = Nothing
    End Sub
    
    0 讨论(0)
提交回复
热议问题