Problem opening Office URI Scheme urls in Office.js on Mac/Safari

Viewed 613

I'm developing a JavaScript addin for Office applications, e.g. Word, Excel and PowerPoint. At some point it should open a file that resides somewhere in SharePoint.

I want the url to open the correct Office application right away and for this purpose I'm using Office URI Schemes (see https://docs.microsoft.com/en-us/office/client-developer/office-uri-schemes?redirectedfrom=MSDN).

Depending on the logic in the app, I'm using two different techniques, which work perfectly when the addin is running in Word, Excel or PowerPoint on Windows.

Technique 1 (normal link)

<a href="ms-word:ofe|u|https://foo.sharepoint.com/path/to/file.docx">Open Me!</a>

Technique 2 (programmatic)

// Js pseudo code
button.onclick = () => {
   window.location = 'ms-word:ofe|u|https://foo.sharepoint.com/path/to/file.docx'
}

As I mentioned, both these techniques works flawlessly on Windows. But when running the addin on e.g. Word Desktop on Mac, absolutely nothing happens. I've debugged the addin, by using "Inspect Element" to open up the console, but there's no errors or anything. It seems to me that the internal browser on Mac silently refuses to open the link.

However, if you paste the link into e.g. a word document, it will open the document if clicked.

Some thoughts:

  • is this related to the manifest.xml for the addin? (still works on windows without modifying the manifest)
  • do I need to enable something on Mac for this to work? (the Office URI Scheme page states these links should work on Office for Mac 2011)

Any input is greatly appreciated.

1 Answers

I found a workaround that works on Mac as well by using window.open(url).

Related