Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean) MsgBox "OK" Cancel = True End Sub
Private WithEvents newIe As InternetExplorer Private WithEvents newIewin As ShellWindows Dim isnew As BooleanPrivate Sub Command1_Click() Set newIewin = New ShellWindows WebBrowser1.Navigate "http://office.9zp.com/index.asp" End SubPrivate Sub newIe_DocumentComplete(ByVal pDisp As Object, URL As Variant) If newIe.LocationURL <> "" Then MsgBox newIe.LocationURL newIe.Quit End If End SubPrivate Sub newIewin_WindowRegistered(ByVal lCookie As Long) If isnew Then Set newIe = newIewin.Item(newIewin.Count - 1) End If End SubPrivate Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean) isnew = True End Sub
MsgBox "OK"
Cancel = True
End Sub
Private WithEvents newIewin As ShellWindows
Dim isnew As BooleanPrivate Sub Command1_Click()
Set newIewin = New ShellWindows
WebBrowser1.Navigate "http://office.9zp.com/index.asp"
End SubPrivate Sub newIe_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If newIe.LocationURL <> "" Then
MsgBox newIe.LocationURL
newIe.Quit
End If
End SubPrivate Sub newIewin_WindowRegistered(ByVal lCookie As Long)
If isnew Then
Set newIe = newIewin.Item(newIewin.Count - 1)
End If
End SubPrivate Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
isnew = True
End Sub
要手工引用一下如下这个DLL
\WINDOWS\SYSTEM\SHDOCVW.DLL
(我在OFFICE的VBA中试时,WebBrowser直接来自SHDOCVW.DLL,VB6中还是来自SHDOCVW.oca)