|
-
Feb 7th, 2007, 02:01 PM
#1
Thread Starter
New Member
Launch IE site and waits until it's fully launched before continuing
Is there a way I can launch a website in VB 6 and have it wait until the site is fully launched before it continues with the rest of my code?
-
Feb 7th, 2007, 02:16 PM
#2
Re: Launch IE site and waits until it's fully launched before continuing
yep
in IE or in the webbrowser control?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 7th, 2007, 02:29 PM
#3
Thread Starter
New Member
Re: Launch IE site and waits until it's fully launched before continuing
-
Feb 7th, 2007, 02:33 PM
#4
Re: Launch IE site and waits until it's fully launched before continuing
add a referecne to the Microsoft Internet Controls
VB Code:
Dim WithEvents IE As InternetExplorer
Private Sub Command1_Click()
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate "http://www.google.com"
End Sub
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is IE.Application) Then
'Your code here
MsgBox "IE IS DONE LOADING"
End If
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 7th, 2007, 03:27 PM
#5
Thread Starter
New Member
Re: Launch IE site and waits until it's fully launched before continuing
Very nice.
A few questions.
1) I would like to incorporate this into a standard module. What would I need to do differently?
2) Can this work without IE being visible?
3) It's actually only fully loaded after the 3rd message box notification. Should I just incorporate a counter which will only continue after the 3rd notification is reached? or is there something else I can do better?
I appreciate your help Static.
-
Feb 7th, 2007, 04:14 PM
#6
Re: Launch IE site and waits until it's fully launched before continuing
1) no. it will not work in a module because it needs the events triggered
2) yeah.. i dont see why not
3) the IF Pdisp code is needed. did you remove the code in the Doc_complete?
why would you load a webpage and not want to see it?
this can be done without IE if you dont need to ever see it
in a module:
VB Code:
Public HDOC As HTMLDocument
Public tmpDOC As HTMLDocument
Public Sub LoadPage(sURL)
Set tmpDOC = New HTMLDocument
Set HDOC = tmpDOC.createDocumentFromUrl(sURL, vbNullString) 'Create it from a URL
Do Until HDOC.ReadyState = "complete"
DoEvents
Loop
End Sub
in form
VB Code:
Private Sub Command1_Click()
LoadPage "http://www.google.com"
Debug.Print HDOC.documentElement.innerHTML
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 8th, 2007, 11:25 AM
#7
Thread Starter
New Member
Re: Launch IE site and waits until it's fully launched before continuing
 Originally Posted by Static
1)
why would you load a webpage and not want to see it?
It's because I'm creating this program that creates a set of Internet Cookies on a user's desktop to access a news site which is subscription-based. We are not allowed to tell users the username and password therefore it's embedded in the cookie.
Unfortunately, in my case, the cookie only works if they launch the website after the cookie has been created or else they are prompted with a username and password. That's why I want to launch it as part of my program and if it's not visible that's fine but not a showstopper.
I've decided to have everything run from the form.
My question for the following code you've submitted:
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is IE.Application) Then
'Your code here
MsgBox "IE IS DONE LOADING"
End If
End Sub
As I mentioned in an earlier post, the msgbox "IE IS DONE LOADING" appears three times before the site is fully loaded but my program continues after the first message. Is there a way to make it wait until the third try?
Please forgive my newbieness...
-
Feb 8th, 2007, 11:30 AM
#8
Re: Launch IE site and waits until it's fully launched before continuing
wow.. thats a first.
the pDisp code is supposed to make it wait till the entire page is done
are there frames? with multiple sources?
do this
VB Code:
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is IE.Application) Then
'Your code here
Debug.Print URL
End If
End Sub
then when its done.. look in the debug window and check the URLs...
whats the last one? run it again... and again.. is it always the same?
your could do
If URL="whatever..." then
Done now
End if
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|