简体   繁体   中英

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." 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. This is quite vital as you don;t want the code to continue executing after it has found what you are after...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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