VBA MS-Word: Is it possible to replace text with wildcard?

后端 未结 2 853
南笙
南笙 2021-01-17 02:18

Is it possible to replace the text that was found using wildcard and replace it with wildcard also? for example FindText:=\"(^13{2}*^13)\", Forward:=True, MatchWildcar

2条回答
  •  借酒劲吻你
    2021-01-17 02:39

    I am not a word developer, but just done this, not complete solution, but a good starting point??? : Text was "Nathan testing Nathan testing"

            dim x as find    
    
        Selection.WholeStory
    
                Set x = Selection.Find
     x.Find.ClearFormatting
                x.Find.Replacement.ClearFormatting
                With x
                    .Text = "Na*han"
                    .Replacement.Text = .Text
                    .Forward = True
                    .Wrap = wdFindAsk
                    .Format = False
                    .MatchCase = False
                    .MatchWholeWord = False
                    .MatchAllWordForms = False
                    .MatchSoundsLike = False
                    .MatchWildcards = True
                End With
    
                x.Execute
                x.Execute Replace:=wdReplaceOne
    

提交回复
热议问题