1

I'm working on an Office Add-In and need to be able to tell if the document was loaded in the standard Office software or Office365 Online.

I've checked the docs and can't find anything.

In office.js, there is an enumeration that looks as if it should be used somewhere, but i can't tell what property/event notifies us of the type. I have also stuck a breakpoint on the Office object and can't see anything.

Microsoft.Office.WebExtension.ApplicationMode={
WebEditor: "webEditor",
WebViewer: "webViewer",
Client: "client"
};

Does anyone know how to do this please?

JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123
  • I'm guessing from this (http://stackoverflow.com/questions/37671721/disable-office-365-outlook-add-in-for-desktop) it's not possible. Will close this question. – JsAndDotNet Jun 09 '16 at 11:44
  • 1
    Only Outlook add-ins have a way to detect if it's in OWA or the client – Eric Legault Jun 09 '16 at 21:30

3 Answers3

2

For reference, in Outlook you can use this to tell the difference between OWA or desktop or mac Outlook:

https://dev.outlook.com/reference/add-ins/Office.context.mailbox.diagnostics.html

Tim Wan
  • 155
  • 6
  • Thanks for the info - Have upvoted. I'm working on PowerPoint, not Outlook, so might try Uservoice to see if something like this can be brought over. – JsAndDotNet Jun 19 '16 at 09:08
2

I know this question was asked a long time ago, but it was something I was also looking for, and then stumbled upon the Office.context object, which gives me all the information I need about the hosting platform of the Office Add-in.

Some examples to follow...

Calling Office.context on macOS, via Outlook Desktop:

{
  contentLanguage: "en-US"
  diagnostics: {
     host: "Outlook", 
     version: "16.47.314.0",
     platform: "Mac"
  },
  displayLanguage: "en-US",
  host: "Outlook",
  isDialog: false,
  platform: "Mac"
}

Calling Office.context on macOS, via Outlook Web:

{
  contentLanguage: "",
  diagnostics: {
    host: "Outlook",
    platform: "OfficeOnline",
    version: "0.0.0.0"
  },
  displayLanguage: "en-US",
  host: "Outlook",
  isDialog: false,
  platform: "OfficeOnline"
}

So looking at the platform value is probably the most useful in your situation, where you can learn if this Add-in is being accessed via the web, mobile, desktop, etc.


All of the possible platform values can be found here: https://learn.microsoft.com/en-us/javascript/api/office/office.platformtype?view=excel-js-preview

The documentation for Office.context Interface can be found here: https://learn.microsoft.com/en-us/javascript/api/office/office.context?view=excel-js-preview#platform

radiovisual
  • 6,298
  • 1
  • 26
  • 41
0

Searching for the same, but in my case for Word not Outlook, I just discovered that this code

        showNotification("url is: " + Office.context.document.url);

gives a URL something like this, in my case

        url is: https://<corp portal name>-my.sharepoint.com/personal/<my name>/Documents/Document15.docx

the number 15 is due to the fact I am currently up to 15 in-named documents in my OneDrive for Business folder (which is where these end up)

On a local client version of Word URL is blank.

Jerry Weeks
  • 317
  • 2
  • 13