ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Webbrowser and DocumentComplete (https://www.excelbanter.com/excel-programming/409343-webbrowser-documentcomplete.html)

grove

Webbrowser and DocumentComplete
 
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

roger

Webbrowser and DocumentComplete
 
"grove" wrote in message
...
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

--
roger



grove

Webbrowser and DocumentComplete
 
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

roger

Webbrowser and DocumentComplete
 
"grove" wrote in message
...
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.

--
roger



grove

Webbrowser and DocumentComplete
 
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



All times are GMT +1. The time now is 02:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com