我正在尝试准备一个查找对话框,用于查找文档中所有突出显示的文本。我尝试使用宏记录器构建它,但它不会显示对话框或查找文本。
这是我的代码:
Sub searchForHighlights()
Dim match As Object
Set match = Application.Dialogs(wdDialogEditReplace)
match.Find.ClearFormatting
match.Find.Highlight = True
With match.Find
.Text = ""
' .Replacement.Text = "" <<< I don't want my text to be replaced
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
match.Show
End Sub
这部分显然是错误的:
Set match = Application.Dialogs(wdDialogEditReplace)