1

我正在尝试准备一个查找对话框,用于查找文档中所有突出显示的文本。我尝试使用宏记录器构建它,但它不会显示对话框或查找文本。

这是我的代码:

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)
4

1 回答 1

1

我提交了部分用于搜索突出显示的文本。但有一件事......我不太明白你的“查找对话框”背后的功能是什么。你能更清楚地描述它吗?

也许您想显示设置了所有选项的“查找对话框”?

Sub FindAllHighlighted()
    Selection.Find.ClearFormatting
    Selection.Find.Highlight = True 'searches for highlighted text
    With Selection.Find
        .Text = ""
        .Replacement.Text = "" 'don't bother it wo'nt replace your text
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
Selection.Find.Execute
End Sub
于 2013-07-23T10:46:01.470 回答