首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.Execute FindText的“模式匹配表达式无效”错误

.Execute FindText的“模式匹配表达式无效”错误
EN

Stack Overflow用户
提问于 2021-04-20 10:25:05
回答 1查看 372关注 0票数 0

下面是昨天起作用的代码:

代码语言:javascript
复制
Sub TestError()

Dim Error As Integer

    With Selection.Find
      .ClearFormatting
      .Font.Bold = True
      .Execute FindText:="Error! Reference source not found."

        If .Found = True Then
           Error = MsgBox("Reference Source error detected - continue with macro?", 4)
              If Error = 7 Then
              Exit Sub
             End If
         End If

    End With

End Sub

它应该搜索"Error!“,如果文档包含该字符串,则应该抛出一个警告,并询问用户是否想继续。

昨天起效了,现在

“查找哪些文本包含无效的模式匹配表达式”

.Execute FindText上。

通常,此错误来自于类似通配符的搜索,其中包含一组未关闭的括号或其他内容。

(我已经试过关掉它了。)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-20 11:45:04

问题很可能是,您以前做过通配符查找,但没有重新设置(尽管您说了相反的话):

代码语言:javascript
复制
Sub TestError()
Dim Error As Long
With Selection.Find
  .ClearFormatting
  .Font.Bold = True
  .MatchWildcards = False
  .Text = "Error! Reference source not found."
  .Execute
  If .Found = True Then
    Error = MsgBox("Reference Source error detected - continue with macro?", 4)
    If Error = 7 Then Exit Sub
  End If
End With
End Sub
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67177059

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档