简体   繁体   English

Excel VBA中的Internet Explorer OLE错误

[英]Internet Explorer OLE error in Excel VBA

I get the follow error from the click line: "Microsoft Excel is waiting for another application to complete an OLE action." 我从单击行中收到以下错误:“ Microsoft Excel正在等待另一个应用程序完成OLE操作。” How can I solve this? 我该如何解决? Thanks for your help. 谢谢你的帮助。

It really annoys me becuase I can't even get the program to stop running, even by pressing several combinations of escape keys, so I have to restart my computer. 这真的让我很烦,因为我什至不能按下几个转义键就无法使程序停止运行,所以我必须重新启动计算机。

     Set objCollection = IE.document.getElementsByTagName("a")

i = 0
While i < objCollection.Length

       If objCollection(i).Title = "The maximum amount of records that may be downloaded is 2,000." Then

                Set objElement = objCollection(i)


        End If


        i = i + 1
  Wend

objElement.Click

Better to use a "For each" to browse through all of the anchors: 最好使用“对于每个”来浏览所有锚点:

Dim objCollection, obj
For each obj in objCollection
    If obj.Title = "The maximum amount of records that may be downloaded is 2,000." Then

    Set objElement = obj

Exit For
    End If
Next obj

I'm assuming there will only be the one result that you are looking for which is why i included the exit clause. 我假设您正在寻找的只是一个结果,这就是为什么我包含了exit子句的原因。 This is quite vital as you don;t want the code to continue executing after it has found what you are after... 这一点非常重要,因为您不希望它在找到所需内容之后继续执行...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM