Is there a foolproof way for the script to wait till the Internet explorer is completely loaded?
Both oIE.Busy
and / or oIE.ReadyState
are not working the way they should:
Set oIE = CreateObject("InternetExplorer.application")
oIE.Visible = True
oIE.navigate ("http://technopedia.com")
Do While oIE.Busy Or oIE.ReadyState <> 4: WScript.Sleep 100: Loop
' <<<<< OR >>>>>>
Do While oIE.ReadyState <> 4: WScript.Sleep 100: Loop
Any other suggestions?
Try this one, it helped me to solve similar problem with IE once:
UPD: Drilling down IE events I found that
IE_DocumentComplete
is the last event before the page is actually ready. So there is one more method to detect when a web page is loaded (note that you have to specify the exact destination URL which may differ from the target URL eg in case of redirection):A few years later, it also hit me. I looked at the proposed solutions and tested a lot. The following combination of commands has been developed, which I will now use in my application.
The second identical loop I did install after it turned out that oIE.Busy = True was sometimes after the first loop.
Regards, ScriptMan
So through looking up this answer, I still had trouble with IE waiting for the page to completely load. In the hopes that this solution will help others, here is what I did:
Basically, what this does is wait for 5 50ms intervals for the number of tagnames loaded to stop increasing. Of course, this is adjustable depending on what you want, but that worked for my application.
try to put this script on the top, this may solve Your problem.
Explanation:
Powershell is not having some rights when you are running script from the normal mode so it is not reading IE status properly and that is why DOM is not being loaded so, script doesn't found any parameter
If your working with IE on a form submission, it's better to place it in a Sub so you can reference the same Sub repeatedly.
The difference being, that your referencing the IE object AFTER the
wscript.sleep
. If you check them first and foremost before the object is loaded. It could cause script failure.I have for a very long time been successfully using:
It has been working perfectly until today, when I changed my PC and switched to Windows 10 and Office 16. Then it started working on some cases, but there were times when the loop was not completed. Neither one of the conditions in the loop was reached, so the loop was ENDLESS.
After a lot of Googling, I have tried many suggestions until I found the solution in this post: Excel VBA Controlling IE local intranet
The solution is to add the URL to the trusted sites list in Internet Explorer Security tab. Finally!