Jela
Jela

Reputation: 572

Find current host in Office add-in

I want to know whether my add-in is running in Word, Excel or Powerpoint. I need a solution that works in the desktop version of the applications (but preferably for the online version as well).

Is this somehow possible?

The reason I'm asking is twofold:

  1. I want to style the add-in app in the colors of the host application.
  2. I submit the document to a webservice. I want to provide a filename as well and need to know if I should postfix with .docx, .xlsx or .pptx.

Upvotes: 1

Views: 52

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33094

There isn't a straightforward way to determine the current host. I would also discourage going down the "single manifest, multiple hosts" path in the first place. As the APIs have matured, more and more functionality has become host specific. The most obvious examples being ExcelAPI and WordAPI.

This isn't to say you should build multiple web apps, just that you should maintain multiple manifests. Each manifest can specify a distinct "landing page" where you can make some session level settings that tell the rest of the App which host it's talking too.

The other benefit of this approach is you can be more selective about which Add-in Commands you declare and where in the ribbon they show up. In some cases you might have functions available in Excel that don't show up at all in Word or PowerPoint.

Upvotes: 1

Related Questions