I am writing VBS code to open Internet Explorer and go to www.google.com However when I run the program, it opens and navigates to www.yahoo.com but the internet explorer is NOT the front window. Can anyone help me with this? Is there a code I can use to bring internet explorer to the front? Thank you all! Here is my code:
Option Explicit
Dim ie
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate("wwww.yahoo.com")
One last question - Is there a code I can use to click a certain button that - specifically one that I can't get to by pressing "tab"?
Thank you all!
Try this:
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://www.yahoo.com/"
Do While ie.Busy : WScript.Sleep 100 : Loop
ie.Visible = True
CreateObject("WScript.Shell").AppActivate ie.document.title
I have found that setting the Visible property to True after calling the AppActivate method works @daniel-cook.
Therefore, simply swapping the last 2 lines in @ansgar-wiechers' example produces the desired result.
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://www.yahoo.com/"
Do While ie.Busy : WScript.Sleep 100 : Loop
CreateObject("WScript.Shell").AppActivate ie.document.title
ie.Visible = True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With