Word VBA Range.Find对象工作不正确 [英] Word VBA Range.Find object worked incorrectly
本文介绍了Word VBA Range.Find对象工作不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现了一件有趣的事情:
在Word 2010中,选择一些文本,然后运行以下VBA代码:
I found an interesting thing:
In word 2010, select some text, and run the following VBA code:
public Sub Test()
With Selection.Range.Find
MsgBox .Execute(Selection.Range.text)
MsgBox .Found
End With
End Sub
两个消息框都说"False",但都应该是"True".为什么?
非常感谢您的建议.
Both the two message box say "False", but both should be "True". Why?
Thanks a lot for your suggestion.
推荐答案
尝试添加ClearFormatting,如下所示:
Try to add ClearFormatting, like this:
public Sub Test()
Selection.Range.Find.ClearFormatting()
With Selection.Range.Find
MsgBox .Execute(Selection.Range.text)
MsgBox .Found
End With
End Sub
http://msdn.microsoft.com/en-us/library/f1f367bx% 28VS.80%29.aspx [ ^ ]
祝你好运!
http://msdn.microsoft.com/en-us/library/f1f367bx%28VS.80%29.aspx[^]
Good luck!
这篇关于Word VBA Range.Find对象工作不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文