本文介绍了Vb:如何将以下行更改为默认Web浏览器:dim webbrowser1 as object = creatobject(" internetexplorer.application")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 如何将以下行更改为默认Web浏览器: Dim WebBrowser1 as object = CreatObject( InternetExplorer.Application) 我的尝试: 1 。 Dim WebBrowser1 as object = CreatObject( LaunchWinApp.exe%1) 2 。 Dim WebBrowser1 as object = CreatObject( default) 解决方案 你没有。 AFAIK,IE是唯一通过COM接口公开的浏览器。 接下来,从CreateObjectAs Object处理返回的类对象,只能访问Object公开的方法和属性,而不是您创建的返回类对象的属性和方法。 如果您想控制所有主流浏览器,请查看 Selenium [ ^ ]。 [已编辑] 使用此代码(VBS / VBA)打开标准浏览器的URL: Dim webbrowser2 设置 webbrowser2 = CreateObject( Wscript.Shell) 如果 webbrowser2 Nothin g 然后 MsgBox 创建WebBrowsewr对象时出错 其他 webbrowser2.Run http:\\www.google.com, 1 ,错误 结束 如果 看一看:脚本展示默认浏览器(针对Win10更新) [ ^ ] wscript.echo浏览器 '识别默认网络浏览器 '作者:JørgenBigom'2015年10月更新功能浏览器缺点t HKEY_CURRENT_USER =& H80000001 Const strKeyPath =Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice Const strValueName =Progid Dim strValue,objRegistry,i '浏览器列表: Dim blist(6,1) blist(0,0)=Intermet Explorer:blist(0,1)=即 blist(1,0)=Edge:blist(1,1)=appxq0fevzme2pys62n3e0fbqa7peapykr8v blist(2,0)=Firefox:blist(2,1)= firefox blist(3,0)=Chrome:blist(3,1)=chrome blist(4,0)=Safari:blist(4,1)= safari blist(5,0)=Avant:blist(5,1)=browserexeurl blist(6,0)=Opera:blist(6,1)= opera Set objRegistry = GetObject(winmgmts:\\.\root\default:StdRegProv) objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPa th,strValueName,strValue 如果是IsNull(strValue)那么 browser =Intermet Explorer(Windows标准):退出函数否则对于i = 0到Ubound(blist, 1)如果Instr(1,strValue,blist(i,1),vbTextCompare)则浏览器= blist(i,0)& - 用户选择:退出功能下一个结束如果 browser =未知的网络浏览器!(签名:'& strValue&')结束功能 How to change the following line to default web browser: Dim WebBrowser1 as object = CreatObject("InternetExplorer.Application")What I have tried:1. Dim WebBrowser1 as object = CreatObject("LaunchWinApp.exe %1")2. Dim WebBrowser1 as object = CreatObject("default") 解决方案 You don't. AFAIK, IE is the only browser exposed through a COM interface.Next, treating the returned class object from CreateObject "As Object", will only get you access to the methods and properties that an Object exposes, not the properties and methods of the returned class object you created.If you want to control all of the major browsers, look into Selenium[^].[EDITED]Use this code (VBS/VBA) to open a URL with standard browser:Dim webbrowser2Set webbrowser2 = CreateObject("Wscript.Shell")If webbrowser2 Is Nothing Then MsgBox "Error on creating WebBrowsewr object"Else webbrowser2.Run "http:\\www.google.com", 1, FalseEnd IfTake a look: Script Show default browser (updated for Win10)[^] wscript.echo browser ' Indentify default web browser ' By Jørgen Bigom ' Updated Oct. 2015 Function Browser Const HKEY_CURRENT_USER = &H80000001 Const strKeyPath = "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" Const strValueName = "Progid" Dim strValue, objRegistry, i ' Browser list: Dim blist(6,1) blist(0,0) = "Intermet Explorer" : blist(0,1) = "ie" blist(1,0) = "Edge" : blist(1,1) = "appxq0fevzme2pys62n3e0fbqa7peapykr8v" blist(2,0) = "Firefox" : blist(2,1) = "firefox" blist(3,0) = "Chrome" : blist(3,1) = "chrome" blist(4,0) = "Safari" : blist(4,1) = "safari" blist(5,0) = "Avant" : blist(5,1) = "browserexeurl" blist(6,0) = "Opera" : blist(6,1) = "opera" Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv") objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue If IsNull(strValue) Then browser = "Intermet Explorer (Windows standard)": Exit Function Else For i = 0 To Ubound (blist, 1) If Instr (1, strValue, blist(i,1), vbTextCompare) Then browser = blist(i,0) & " - User choice": Exit Function Next End If browser = "Unknown web browser! (signature: '" & strValue & "')" End Function 这篇关于Vb:如何将以下行更改为默认Web浏览器:dim webbrowser1 as object = creatobject(" internetexplorer.application")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 12:55