下面是昨天起作用的代码:
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上。
通常,此错误来自于类似通配符的搜索,其中包含一组未关闭的括号或其他内容。
(我已经试过关掉它了。)
发布于 2021-04-20 11:45:04
问题很可能是,您以前做过通配符查找,但没有重新设置(尽管您说了相反的话):
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 Subhttps://stackoverflow.com/questions/67177059
复制相似问题