Excel hyperlink opens in two tabs in default browser

Navnath Kumbhar 1 Reputation point
2022-06-09T14:15:10.003+00:00

Hello,

I am facing this strange issue with MS Excel (also with MS Word and MS PowerPoint).
When I create a hyperlink in Excel and click to open it, it opens in two tabs in my default browser.
I found some articles on web regarding this issue and most of the times I get this suggestion: cannot-locate-server-when-click-hyperlink

But, it did not help me. I tried to change the default browser but it also did not help.
Is this issue really exist and well documented somewhere in Microsoft documentation?

As a workaround, I decided to open the hyperlink using FollowHyperlink event as below: [Because I wanted to prevent default Excel hyperlink click behavior]

sheet.FollowHyperlink += new Microsoft.Office.Interop.Excel.DocEvents_FollowHyperlinkEventHandler(HandleHyperlink);  
  
void HandleHyperlink(Microsoft.Office.Interop.Excel.Hyperlink Target)  
    {             
        System.Diagnostics.Process.Start(Target.Address);  
     }  

It opened the hyperlink but did not prevent default click behavior of Excel. This time hyperlink is opened in 3 tabs (2 tabs with default Excel behavior and one with this HandleHyperlink callback)
Do you have any solution for this? Any Excel API?

[FYI, I tried the hyperlink click behavior in OpenOffice and Libreoffice. This issue does not exist there.]

I am using Windows 10.
Excel version: 2016 (16.0.5317.1000) MSO (16.0.5278.1000) 32 bit

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Excel | For business | Windows
{count} votes

3 answers

Sort by: Most helpful
  1. Navnath Kumbhar 1 Reputation point
    2022-06-10T15:15:35.067+00:00

    Any solution for this please?

    0 comments No comments

  2. Xavier Junqué i de Fortuny 20 Reputation points
    2024-09-04T20:58:32.25+00:00

    I came up to this thread because of the same problem. Finally I have done the following trick:

    a) a new blank window 'wnd' is open

    b) set 'wnd' location to the path to the Excel file, then

    c) Excel opens itself in a new tab (just one tab, instead of two)

    d) wait some time to close 'wnd' as it is not needed no more.

                        var wnd = window.open("", "_blank", "height=180px, width=180px");
                        wnd.location = uri;
                        setTimeout(x => wnd.close(), 2000); 
    
    0 comments No comments

  3. Xavier Junqué i de Fortuny 20 Reputation points
    2024-09-05T12:03:33.01+00:00

    Seems that the problem has to do with how the source path is formed, because this code works like a charm opening Excel in a new window:

      var url = "https://view.officeapps.live.com/op/view.aspx?src=";
      var src = "https://mydomain.xxx" + encodeURIComponent("/folder/.../Excelxx.xls");
      window.open(url + src, "_blank", "width=500px, height=500px");
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.