lundi 20 avril 2015

How to change text format using wildcards in VBA

Our Word documents have several occurrences of the text "Division XX" where XX ranges from 00 thru 99. I need to boldface these using VBA. Below is some code I adopted which gets me part way

With mDoc.Tables(1).Cell(1, 1).Range.Find
       .Forward = True
       .Wrap = wdFindStop
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
       .Replacement.Font.Bold = True

       .Execute FindText:="Division", Format:=True, ReplaceWith:="Division", Replace:=wdReplaceAll
    End With

However, it doesn't select or highlight the " XX". I tried and failed to use wildcards because it wasn't clear to me what to use for the ReplaceWith value?

Aucun commentaire:

Enregistrer un commentaire