admin管理员组文章数量:1605045
VBA调用浏览器打开指定网页的几种方法
下面的几段VBA代码都可以打开浏览器并打开指定的网页:
方法一:用API打开默认的浏览器
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub OpenWebPage1()
ShellExecute 0&, vbNullString, "http://www.doczj/doc/f9c42ac777232f60dccca141.html", vbNullString, vbNullString, vbNormalFocus
End Sub
方法二:用“FollowHyperlink”方法:
Sub OpenWebPage2()
ActiveWorkbook.FollowHyperlink
Address:="http://www.doczj/doc/f9c42ac777232f60dccca141.html", NewWindow:=True
End Sub
注意网址中要包含“http://”。
方法三:用“InternetExplorer”对象
Sub OpenWebPage3()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate ("http://www.doczj/doc/f9c42ac777232f60dccca141.html")
End Sub
方法四:用Shell语句
这个方法可以用指定的浏览器打开某个网页。例如调用IE打开网址“http://www.doczj/doc/f9c42ac777232f60dccca141.html”
Sub OpenWebPage4()
Dim url As String
url = "http://www.doczj/doc/f9c42ac777232f60dccca141.html"
版权声明:本文标题:vba打开html文件,VBA调用浏览器打开指定网页的几种方法 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1724926044a997900.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论