Redirection from Internet Explorer to Microsoft Edge for compatibility with modern web sites

Sanju4C5 1 Reputation point
2022-11-07T11:22:58.207+00:00

Hi Team,

Good Day!!

Our Macro Application project is using the SHDocVw DLL reference, to set some browser properties, after which a link is opened in the Internet Explorer application.

However, as the Internet Explorer application is retired, we are trying to migrate to Microsoft Edge. Since the SHDocVw reference is only applicable for the Internet Explorer browser, we're unable to find how the same can be replicated for the Microsoft Edge browser.

We tried the below code for opening links in the Microsoft Edge browser, but we're unable to set the browser properties, like we set using the SHDocVw reference:

SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();

foreach (SHDocVw.InternetExplorer ie in shellWindows)

{ if (ie.FullName.Contains("IEXPLORE"))

{ try

{

doc = ie.Document; if (doc.url.Contains("https://www.google.com/"))

{

TempBrowser = ie; CurrentTitle = doc.title; break; } }

catch { }

} }

Application.DoEvents();

}

while (TempBrowser.Busy || TempBrowser.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE)

{ Application.DoEvents();

Kindly check and let us know, How can we modify the SHDocVw.ShellWindows(), method and properties to Microsoft edge.

Thank you

Sanju

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,238 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. ShiJieLi-MSFT 8,731 Reputation points Microsoft Vendor
    2022-11-08T06:30:16.947+00:00

    Hi @Sanju4C5 ,

    As you've said, the SHDocVw reference is only applicable for Internet Explorer. If you are trying to complete the automation in Edge, here're 2 workarounds for you:

    1. Use IE mode. IE mode maintains the support for SHDocVw reference but is just slightly different from how you deal with IE. To make it work, you need to
      a. Enable IE mode. From this doc, you can find a step-by-step IE mode configuration tutorial.
      b. Disable Internet Explorer 11 as a standalone browser. You need to enable this policy to disable Internet Explorer, which prevents SHDocVw from failing to find IE mode windows.
      c. Enable global window list in Internet Explorer mode. You need to enable this policy to allow the IE Mode windows to show up in the global window list.
      Then, you are supposed to be able to interact with IE mode.
    2. Use WebDriver like Selenium. Selenium has a full support for Edge automation, so you won't worry about the compatibility problems. If you have any interest, you can check this automation tutorial.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,
    Shijie Li

    0 comments No comments

  2. Sanju4C5 1 Reputation point
    2022-11-11T18:04:45.47+00:00

    Hi Team,

    Thank you for sharing the information.

    We followed the same as you suggested, but unfortunately it's not working as expected. Just it opened the login page in Edge as IE mode.

    We have been developing an Excel/VBA program for over 12 years and it is up to 2000 lines of code and an extensive use of Excel spread sheet. Now that Edge has taken over IE. the our program no longer works. The need is to invoke a browser and set a URL.

    I also have a program in Excel vba which needs to open a browser like:

    Set ie = CreateObject("InternetExplorer.Application")
    With ie
    .Visible = True
    .navigate "https://www.example.com"
    Do Until .readyState = 4: DoEvents: Loop ....................

    The problem is that the code ALWAYS opens IE11. How can I have the code open Edge instead? what will happen after June 22 when IE gets deprecated?

    Thank you,
    Sanjeev


  3. Sanju4C5 1 Reputation point
    2022-11-14T08:49:10.14+00:00

    Hi Shijie,

    Please ignore the previous code.

    Thank you for sharing the information.

    We followed the same as you suggested, but unfortunately it's not working as expected. Just it opened the login page in Edge as IE mode.

    We have been developing an Excel/VBA program for over 12 years and it is up to 2000 lines of code and an extensive use of Excel spread sheet. Now that Edge has taken over IE. the our program no longer works. The need is to invoke a browser and set a URL.

    I also have a program in Excel vba which needs to open a browser like:

    SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();

    foreach (SHDocVw.InternetExplorer ie in shellWindows)

    { if (ie.FullName.Contains("IEXPLORE"))

    { try

    {

    doc = ie.Document; if (doc.url.Contains("https://www.google.com/"))

    {

    TempBrowser = ie; CurrentTitle = doc.title; break; } }

    catch { }

    } }

    Application.DoEvents();

    }

    while (TempBrowser.Busy || TempBrowser.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE)

    { Application.DoEvents();

    The problem is that the code ALWAYS opens IE11. How can I have the code open Edge instead? what will happen after June 22 when IE gets deprecated?

    Thank you
    Sanju