Switching from Internet Explorer to Microsoft Edge

匿名 (未验证) 提交于 2019-12-03 01:23:02

问题:

After the recent release of Windows 10, including the new browser - Microsoft Edge - would anyone simply know how to open Microsoft Edge browser via Excel VBA. I have tried searching the website without any luck.

This is the current basic Excel VBA coding I use to open the Internet Explorer:

Sub xyz()  Dim Browser As SHDocVw.InternetExplorer 'Microsoft Internet Controls Dim HTMLdoc As MSHTML.HTMLDocument 'Microsoft HTML Object Library Dim URL As String    URL = "http://www.bbc.co.uk/news"   Set Browser = New InternetExplorer     Browser.Silent = True     Browser.navigate URL     Browser.Visible = True   Do     Loop Until Browser.readyState = READYSTATE_COMPLETE      Set HTMLdoc = Browser.document  End Sub

This is a very straight forward piece of VBA coding to open the BBC website for example.

However, what is the new piece of coding to open Microsoft Edge?

回答1:

According to MS here, IE11 ships with Windows 10

The default browser for Windows 10 is Microsoft Edge, which is powered by our new rendering engine and is our path forward for the Web on Windows. Site developers should focus their testing on Microsoft Edge for new and existing experiences. Internet Explorer 11 will be included for some legacy scenarios and users will be have the option to choose it as the default browser, like with any other browser.

So existing code for IE should continue to work. Not tried it though.

Some technical stuff on Edge can be found here

As of Mon 10-Aug-2015, I have upgraded one PC from Win 7 Pro SP1 to Win 10 Pro and the code you supplied works fine. IE11 runs fine and shows the website. The IE11 download page confirms that I've already got it installed.



回答2:

I had a similar issue upon updating to Windows 10. Turns out 'Microsoft Internet Controls' and 'Microsoft HTML Object Library' had been "removed" from 'References'. Adding them resolved the problem and code worked fine without requiring any alterations. Don't know if this helps.



回答3:

This may not be an answer but it worked for me.

The Internet Explorer object will still open through VBA in Windows 10 using IE11. However, I had to ask Cortana to open IE11 first so it would sort out all of it's "first time use" pop-ups and what not. "Welcome to IE11" and "Let's get started" etc.

Once I got through all that and closed the browser. I re-ran my macro and the browser object came up fine and worked as normal. Hope this helps someone.

P.S. I'm using the CreateObject method of creating the browser window.



回答4:

how to open Microsoft Edge browser via Excel VBA

VBS/VBA uses the COM object model (ActiveX) to communicate with desktop processes and this feature will not be made available for Edge.

Fortunately newer cross-browser solutions (i.e. WebDriver) exist for automation and Edge adopts these new standards. Unfortunately, to use them, the techniques used will need to change.

Duplicate of Will Microsoft Edge support COM automation (InternetExplorer object)?.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!