1
我在Word 2007中記錄了一個查找單詞的宏,將光標向上移動兩行,插入三個'***',然後突出顯示該行。它適用於找到的單詞的第一個實例。我正努力讓它在整個文檔中重複出現我想要查找的單詞的所有實例。查找文本和格式
這是我錄製的宏的輸出。我需要對每個「B」實例重複這些操作。
Sub HighlightNewItems()
'
' HighlightNewItems Macro
'
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "B,"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.TypeText Text:="***"
Selection.TypeParagraph
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Options.DefaultHighlightColorIndex = wdRed
Selection.Range.HighlightColorIndex = wdRed
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub