Search code examples
excelvbamicrosoft-edgegetelementbyid

Upgrading From IE to EDGE


I need VBA Code translation for Edge. I’m in a Window10/Excel 16 environment. I have been using Internet Explorer (IE) when I scrape data from websites. Now, I am needing to upgrade to Microsoft Edge. I am having to translate some code and I am finding I need some help.

I used to call the URL https://www.azblue.com/individualsandfamilies/ using “IE.navigate”. Ex:

IE.navigate "https://www.azblue.com/individualsandfamilies/"

But, what I cannot figure out is how to use these other lines of Code with Edge. Here are a 3 lines of code (disjointed) that I use often and need to know the syntax translation for Edge:

IE.document.getElementById("lockedcontent_0_maincolumn_2_twocolumn2fb4d204091d44aa08196ef423877fd9f_0_ToolbarUsernameControl").Focus

IE.document.getElementById("lockedcontent_0_maincolumn_2_twocolumn2fb4d204091d44aa08196ef423877fd9f_0_ToolbarUsernameControl").Value = "MyUserName" 

IE.document.Focus

Of course, any help is greatly appreciated Thanks!


Solution

  • Microsoft Edge browser doesn't support the COM automation interface that used in VBA. If you want to automate Microsoft Edge, you should use WebDriver.

    To get started using WebDriver, you will need to download a testing framework of your choice along with an appropriate language binding and the MicrosoftWebDriver server.

    We usually use Selenium and you could download the language binding in this page. At the same time, you could download Microsof Edge WebDriver in this page.

    Reference link: Will Microsoft Edge support COM automation (InternetExplorer object)?