打开网页-------------------------------------------------------------------------------- 打开VB菜单的 Project|References 项,在References对话框中有一个Microsoft Internet Control项,选中它,然后在Form1中加入一个CommandButton,在Form1中加入一下代码: 'Dim dWinFolder As ShellLinkObject Dim dWinFolder As ShellWindows
Private Sub Command1_Click() bBrowser = False If dWinFolder.Count = 0 Then '没有打开的浏览器窗口,执行常规的ShellExecute 打开网页 Else dWinFolder.Item(0).Navigate "file:///c:/windows/temp/a.htm", navOpenInNewWindow, _ "_blank", 0, 0 End If End Sub
Private Sub Form_Load() Set dWinFolder = New ShellWindows End Sub
Private Sub Form_Unload(Cancel As Integer) Set dWinFolder = Nothing End Sub 运行程序,就可以在新窗口中打开了。ShellWindows对象是Windows下运行的所有外壳浏览器的集合。用CreateProcess "C:\Program Files\Internet Explorer\Iexplore.exe " YourURL
打开VB菜单的 Project|References 项,在References对话框中有一个Microsoft Internet Control项,选中它,然后在Form1中加入一个CommandButton,在Form1中加入一下代码:
'Dim dWinFolder As ShellLinkObject
Dim dWinFolder As ShellWindows
Private Sub Command1_Click()
bBrowser = False
If dWinFolder.Count = 0 Then
'没有打开的浏览器窗口,执行常规的ShellExecute 打开网页
Else
dWinFolder.Item(0).Navigate "file:///c:/windows/temp/a.htm", navOpenInNewWindow, _
"_blank", 0, 0
End If
End Sub
Private Sub Form_Load()
Set dWinFolder = New ShellWindows
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set dWinFolder = Nothing
End Sub
运行程序,就可以在新窗口中打开了。ShellWindows对象是Windows下运行的所有外壳浏览器的集合。用CreateProcess "C:\Program Files\Internet Explorer\Iexplore.exe " YourURL