将浏览器从Internet Explorer更改为Microsoft Edge在VBA脚本中

huangapple go评论91阅读模式
英文:

Changing browser from internet explorer to Microsoft edge in VBA script

问题

我有一段代码,在其中使用以下代码段在“Internet Explorer”中打开URL。

Dim IE As Object
Set IE = New InternetExplorerMedium
IE.Visible = True
IE.Navigate URL


现在我将其更改为以下内容

Dim IE As Object
Set IE = CreateObject("MSEdge.Application")
IE.Visible = True
IE.Navigate URL


然后我遇到了以下行的“运行时错误 '429' ActiveX组件无法创建对象”

Set IE = CreateObject("MSEdge.Application")


我尝试修复它,但陷入了死胡同,有人可以帮我修复这个错误吗?

我希望在Microsoft Edge中打开一个URL。
英文:

I have a code where I open an URL in "Internet Explore" using the following piece of code.

Dim IE As Object
Set IE = New InternetExplorerMedium
IE.Visible = True
IE.Navigate URL

now I changed it to as follows

Dim IE As Object
Set IE = CreateObject("MSEdge.Application")
IE.Visible = True
IE.Navigate URL

and I ran into "run time error '429' ActiveX component can't create a object" at the following line

Set IE = CreateObject("MSEdge.Application")

I tried to fix it but ran into a dead end, can someone help me to fix the error?

I am expecting to open an url in Microsoft edge

答案1

得分: 0

Microsoft Edge不支持COM自动化接口,因此无法使用传统的VBA方式自动化Microsoft Edge。要自动化Microsoft Edge,通常可以:

  1. 如果需要坚持使用VBA,可以使用SeleniumBasic。你可以参考此已接受的答案作为示例。
  2. 迁移到Selenium,如果你愿意转向其他语言,Selenium会不断更新以更好地支持现代浏览器。
英文:

Microsoft Edge does not support the COM automation interface so you won't be able to use the traditional VBA way to automate Microsoft Edge. To automate Microsoft Edge, normally you can:

  1. Use SeleniumBasic if you need to stick to VBA. You can refer to this accepted answer as an example.
  2. Move to Selenium if you are willing to switch to other languages, which keeps receiving updates to support modern browsers better.

huangapple
  • 本文由 发表于 2023年4月19日 17:05:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76052662.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定