|
Sub FindAndReplaceMultiItems()'Update by ExtendOffice 2018/10/25 Dim xFind As String Dim xReplace As String Dim xFindArr, xReplaceArr Dim I As Long Application.ScreenUpdating = False xFind = InputBox("Enter items to be found here,seperated by comma: ", "Kutools for Word") xReplace = InputBox("Enter new items here, seperated by comma: ", "Kutools for Word") xFindArr = Split(xFind, ",") xReplaceArr = Split(xReplace, ",") If UBound(xFindArr) <> UBound(xReplaceArr) Then MsgBox "Find and replace characters must be equal.", vbInformation, "Kutools for Word" Exit Sub End If For I = 0 To UBound(xFindArr) Selection.HomeKey Unit:=wdStory With Selection.Find .ClearFormatting .Replacement.ClearFormatting .Text = xFindArr(I) .Replacement.Text = xReplaceArr(I) .Format = False .MatchWholeWord = False End With Selection.Find.Execute Replace:=wdReplaceAll Next Application.ScreenUpdating = TrueEnd Sub
这是代码,我想输入用,号分隔的单词后,查找完成后改成红色,这个是替换的。 新手小白一个,不懂VB,谢谢老师了
|
|