编译错误:突出显示宏中的参数不可选

时间:2017-04-18 14:56:01

标签: vba excel-vba word-vba excel

我正在尝试在Excel中创建一个宏来突出显示某组单词以支持关键字搜索分析。我在word-vba中有这个宏。我需要更改以转换为excel-vba。目前,我一直收到错误消息

  

编译错误:参数不可选

并突出显示.Find文本,因此这可能是要解决的主要问题。

有没有人对如何修复/翻译excel有任何建议?

Sub HighlightTargets()

    Dim range As range
    Dim i As Long
    Dim TargetList

    TargetList = Array("password", "login", "account")

    For i = 0 To UBound(TargetList)
        Set range = ActiveDocument.range

        With range.Find
            .Text = TargetList
            .Format = True
            .MatchCase = True
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False

            Do While .Execute(Forward:=True) = True
                range.HighlightColorIndex = wdYellow
            Loop
        End With
    Next
End Sub

0 个答案:

没有答案