open internet explorer to a url
Moderators: Dorian (MJT support), JRL
open internet explorer to a url
i tried doing this:
Run Program>C:\Program Files\Internet Explorer\iexplore.exe
WAIT >5
Press Tab
Send>http:www.yahoo.com
Press Enter
is there an easier way?
Run Program>C:\Program Files\Internet Explorer\iexplore.exe
WAIT >5
Press Tab
Send>http:www.yahoo.com
Press Enter
is there an easier way?
Hi,
Yes. And your way is unreliable. What if it takes longer than 5 seconds for the page to load? You must not have discovered the Scripts & Tips archive on our web site yet or the search function on this forum because there are lots of topics about this.
Check this out at Scripts & Tips for the best way to do what you want:
https://www.mjtnet.com/scripts.hts?display+77
Yes. And your way is unreliable. What if it takes longer than 5 seconds for the page to load? You must not have discovered the Scripts & Tips archive on our web site yet or the search function on this forum because there are lots of topics about this.
Check this out at Scripts & Tips for the best way to do what you want:
https://www.mjtnet.com/scripts.hts?display+77
MJT Net Support
[email protected]
[email protected]
So is:
Run Program>C:\Program Files\Internet Explorer\iexplore.exe http://www.mjtnet.com
WaitWindowOpen>Microsoft Internet Explorer
unreliable too?
Run Program>C:\Program Files\Internet Explorer\iexplore.exe http://www.mjtnet.com
WaitWindowOpen>Microsoft Internet Explorer
unreliable too?
Yes, because this only waits for Internet Explorer to be active. It doesn't know when the web page you have requested has finished loading.
The title of the web page appears in the Internet Explorer bar so you could do WaitWindowOpen>title* but this is no good either because IE puts the web pages' title in the bar before it has finished loading the rest of the page.
So the only reliable way to do it is to use a method that Internet Explorer GIVES us to use - the Busy function exposed by Internet Explorer's ActiveX interface:
Sub OpenPage(URL,Wait)
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
IE.navigate URL
do while IE.Busy and Wait
loop
End Sub
This function takes a URL and if you set Wait to 1 the loop keeps looping until Busy is no longer true. Simple, elegent, and reliable. There is no point in not using a nice feature that is there for the taking!
The title of the web page appears in the Internet Explorer bar so you could do WaitWindowOpen>title* but this is no good either because IE puts the web pages' title in the bar before it has finished loading the rest of the page.
So the only reliable way to do it is to use a method that Internet Explorer GIVES us to use - the Busy function exposed by Internet Explorer's ActiveX interface:
Sub OpenPage(URL,Wait)
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
IE.navigate URL
do while IE.Busy and Wait
loop
End Sub
This function takes a URL and if you set Wait to 1 the loop keeps looping until Busy is no longer true. Simple, elegent, and reliable. There is no point in not using a nice feature that is there for the taking!
MJT Net Support
[email protected]
[email protected]
Use the TimeValue and Now functions. Get the time before the loop and keep checking the time in the loop. If the timeout interval has elapsed exit the loop.
MJT Net Support
[email protected]
[email protected]
Sub OpenPage(URL,Wait)
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
IE.navigate URL
do while IE.Busy and Wait
loop
End Sub
I a beginner at this... How do I add this code to a subroutine so that I can go to different web pages and make sure the page is fully loaded before I go to the next page
Thanks
Nate
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
IE.navigate URL
do while IE.Busy and Wait
loop
End Sub
I a beginner at this... How do I add this code to a subroutine so that I can go to different web pages and make sure the page is fully loaded before I go to the next page
Thanks
Nate
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Those are VB Script subroutines, you define them at the beginning of the macro between VBSTART and VBEND tags and call them as many times as you need with VBRun> in the script. Like this:
//Define the VBScript subroutines
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
End Sub
Sub Navigate(URL)
IE.navigate URL
End Sub
Sub WaitBusy
do while IE.Busy
loop
End Sub
Sub DestroyIE
IE.Quit
Set IE = Nothing
End Sub
VBEND
//Main Program
//Web Page1
VBRun>CreateIE
VBRun>Navigate,http://www.yahoo.com
VBRun>WaitBusy
Wait>1
SetFocus>Microsoft Internet Explorer*
WindowAction>1,Microsoft Internet Explorer*
//Do your stuff here (Wait> is just for demo)
Wait>2
//Close IE
VBRun>DestroyIE
//Web Page2
VBRun>CreateIE
VBRun>Navigate,http://www.msn.com
VBRun>WaitBusy
Wait>1
SetFocus>Microsoft Internet Explorer*
WindowAction>1,Microsoft Internet Explorer*
//Do your stuff here (Wait> is just for demo)
Wait>2
//Close IE
VBRun>DestroyIE
Label>finish
//Define the VBScript subroutines
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 1
End Sub
Sub Navigate(URL)
IE.navigate URL
End Sub
Sub WaitBusy
do while IE.Busy
loop
End Sub
Sub DestroyIE
IE.Quit
Set IE = Nothing
End Sub
VBEND
//Main Program
//Web Page1
VBRun>CreateIE
VBRun>Navigate,http://www.yahoo.com
VBRun>WaitBusy
Wait>1
SetFocus>Microsoft Internet Explorer*
WindowAction>1,Microsoft Internet Explorer*
//Do your stuff here (Wait> is just for demo)
Wait>2
//Close IE
VBRun>DestroyIE
//Web Page2
VBRun>CreateIE
VBRun>Navigate,http://www.msn.com
VBRun>WaitBusy
Wait>1
SetFocus>Microsoft Internet Explorer*
WindowAction>1,Microsoft Internet Explorer*
//Do your stuff here (Wait> is just for demo)
Wait>2
//Close IE
VBRun>DestroyIE
Label>finish