Webbrowser and DocumentComplete

G

grove

I am using the DocumentComplete event to grab the text from a web
page. The MS documentation suggests of course I need to check the
page has finally loaded.

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object,
URL As Variant)
If (pDisp Is WB.Object) Then
Debug.Print "Web document is finished downloading"
End If
End Sub

When I try this it complains that "Object doesn't not support this
property or method"

What's wrong?

grove
 
R

roger

grove said:
I am using the DocumentComplete event to grab the text from a web
page. The MS documentation suggests of course I need to check the
page has finally loaded.

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object,
URL As Variant)
If (pDisp Is WB.Object) Then
Debug.Print "Web document is finished downloading"
End If
End Sub

When I try this it complains that "Object doesn't not support this
property or method"

What's wrong?

Is it because you are using "WebBrowser1" and "WB" in the same procedure?

If that's not the reason, does this work?

"If (pDisp Is WB) Then"


Curiously
"pDisp Is WB.Object"
works in MSAccess, but not in my version of Excel
 
G

grove

WebBrowser1 was just my typo when I was cutting and pasting to this
post.

"If (pDisp Is WB) Then"

Certainly does work and gives the correct result in my procedure, so
seems an error in the documentation. Worrying that there appears to
be some inconsistency with versions of Excel.

If you have any ideas why, or find which is the correct syntax for
your version, perhaps you would let me know. I am on Excel 2002 SP3.

Thanks

grove
 
R

roger

grove said:
WebBrowser1 was just my typo when I was cutting and pasting to this
post.

"If (pDisp Is WB) Then"

Certainly does work and gives the correct result in my procedure, so
seems an error in the documentation. Worrying that there appears to
be some inconsistency with versions of Excel.

If you have any ideas why, or find which is the correct syntax for
your version, perhaps you would let me know. I am on Excel 2002 SP3.

Sorry, I don't know. I am using the same version of Excel.

Perhaps it's one of the 1483279 bugs and features that nobody ever got
around to fixing.
 
G

grove

I probably need to start a new thread, but I will give it a try.

This code works fine in Excel 2002


Private Sub WB_DocumentComplete(ByVal pDisp As Object, URL As Variant)

Dim sGetText As String

If (pDisp Is WB) Then
sGetText = WB.Document.Body.InnerText

....do something with sGetText ...

End Sub


But in Excel 2003 "sGetText" is empty for the same web page.

Thanks

grove
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top