Hi All,
I'm using the "Webbrowser" object to get html code from internet explorer (so I can parse it and make a text-only browser).
I declare the WebBrowser object as follows:
1. Public WithEvents WebBrowser1 As WebBrowser
2. Private Sub Form_Load()
Set WebBrowser1 = New InternetExplorer
End Sub
Problem is that I need to get any pop-up windows IE might create, during browsing. So, using the "NewWindow2" event sounds like a good bet. As follows:
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, _
Cancel As Boolean)
Unfortunately, everytime this event fires, the ppdisp = Nothing and so I can't do anything with this.
I then try to get a new instance of my own text-based browser to launch, but because "ppdisp" is Nothing, the program crashes. The code is as follows:
Private Sub WebBrowser1_NewWindow2(ppDisp As Object,_
Cancel As Boolean)
Dim frmWB As frmMain
'if an object is passed correctly
If (ppDisp Is WebBrowser1.object) Then
Cancel = False 'don't close the new window
Set frmWB = New frmMain 'create new form
frmWB.Visible = True 'make new form visible
'register new browser
frmWB.WebBrowser1.RegisterAsBrowser = True
Set ppDisp = frmWB.WebBrowser1.object
End If
End Sub
If anyone has any ideas about this please let me know, because there doesn't seem to be any documentation out there anywhere.
Any help is much appreciated.
Thanks in advance.
James.
I'm using the "Webbrowser" object to get html code from internet explorer (so I can parse it and make a text-only browser).
I declare the WebBrowser object as follows:
1. Public WithEvents WebBrowser1 As WebBrowser
2. Private Sub Form_Load()
Set WebBrowser1 = New InternetExplorer
End Sub
Problem is that I need to get any pop-up windows IE might create, during browsing. So, using the "NewWindow2" event sounds like a good bet. As follows:
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, _
Cancel As Boolean)
Unfortunately, everytime this event fires, the ppdisp = Nothing and so I can't do anything with this.
I then try to get a new instance of my own text-based browser to launch, but because "ppdisp" is Nothing, the program crashes. The code is as follows:
Private Sub WebBrowser1_NewWindow2(ppDisp As Object,_
Cancel As Boolean)
Dim frmWB As frmMain
'if an object is passed correctly
If (ppDisp Is WebBrowser1.object) Then
Cancel = False 'don't close the new window
Set frmWB = New frmMain 'create new form
frmWB.Visible = True 'make new form visible
'register new browser
frmWB.WebBrowser1.RegisterAsBrowser = True
Set ppDisp = frmWB.WebBrowser1.object
End If
End Sub
If anyone has any ideas about this please let me know, because there doesn't seem to be any documentation out there anywhere.
Any help is much appreciated.
Thanks in advance.
James.