1

Because the variety of Office clients that support add-ins is quite large we want to serve some slightly different experiences to the different clients (also to circumvent some irregularities and bugs in some of the clients). There does not seem to be an API function in the office.js library to actually surface the host application? How would we 'detect' what client our add-in is hosted in?

JVermeulen
  • 225
  • 4
  • 8
  • @Nicu, we are evaluating adding an API to detect host ("Excel, Word, Outlook, etc) & platform (Desktop, Mac, Web, etc) info. To make sure we're taking it into account, would you mind describing the list of use-cases you have for the API? Also, are you looking at just host, or platform, or version?..: basically, what do you envision using, and for what, if the API were provided? Thanks! – Michael Zlatkovsky - Microsoft Sep 26 '16 at 14:10

2 Answers2

0

At present, the Office ad-in API doesn't provide the API to get the client info. However, the Office will append the _host_Info query string to describe the host.

For example, here is an URL of Excel task pane add-in running on Windows: https://localhost:44345/App/Home/Home.html?_host_Info=Excel|Win32|16.01|en-US

As a workaround, we can get the client info from this query string.

Fei Xue
  • 14,369
  • 1
  • 19
  • 27
  • Regarding checking the app url: please be aware that it's a "hack", in that it's an undocumented behavior that may or may not change in the future. The link that Jessevl mentions (http://stackoverflow.com/questions/32840459/neat-ways-to-get-environment-i-e-office-version/32851938#32851938) is the only reliable/"supported" way to find out the host. Please see both the answer itself and the comments to it. – Michael Zlatkovsky - Microsoft Jun 27 '16 at 14:25
0

While the add-in API does not provide you an API call to see what the host is there are ways to do feature detection, so the actual question is: why do you want to know the host. You could instead detect whether some of the more 'unusual' features are available, and if they are not fall back to some other method. You can find a VERY elaborate explanation here.

Indeed if you really want to detect the host, you can check the requested URL because it appends to app url with information on the host (client & version).

Community
  • 1
  • 1
Jessevl
  • 909
  • 1
  • 6
  • 4
  • Regarding checking the app url: please be aware that it's a "hack", in that it's an undocumented behavior that may or may not change in the future. The link that Jessevl mentions (http://stackoverflow.com/questions/32840459/neat-ways-to-get-environment-i-e-office-version/32851938#32851938) is the only reliable/"supported" way to find out the host. Please see both the answer itself and the comments to it. – Michael Zlatkovsky - Microsoft Jun 27 '16 at 14:25