代码在其他系统上performance不同

这是我在其他系统上工作的LOC。 此代码是用VBA Excel编写的,并在PowerPoint文件上执行search操作。

Set oTmpRng = oTxtRng.Find( _ FindWhat:=searchtext, _ WholeWords:=False, _ matchcase:=matchvalue) 

在这里,如果search文本中的单词在PowerPoint文件中不存在,那么它会在我的系统中返回“Nothing”,但同样在我的同事系统中返回空白(“”)。 还有一件事,oTmpRng =我的系统中没有任何东西被返回,在这种情况下,下面的代码行不应该执行。 但它仍然在里面。

 If Not oTmpRng Is Nothing and oTmpRng <> "" Then msg "It should not execute" '<- This line should not execute when oTmpRng=Nothing End If 

注意:两个系统都由Office 2007组成。任何人都可以告诉我为什么会发生这种情况。

接下来在代码中有错误的地方吗? 这可能会导致在条件有错误时总是执行。

否则,不具有最低优先级,所以我总是使用括号,有些东西尝试:

 If (Not oTmpRng Is Nothing) and oTmpRng <> "" Then msg "It should not execute" '<- This line should not execute when oTmpRng=Nothing End If 

要么

 If Not (oTmpRng Is Nothing and oTmpRng = "") Then msg "It should not execute" '<- This line should not execute when oTmpRng=Nothing End If