A deeper look at Microsoft Office Add-in
The intend of this article is to understand the overall flow of Microsoft Office Add-in. It is recommended to have a basic understanding of office Add-in platform before reading this article.
Step 1: An Office Add-in comprises 2 basic components: an XML manifest file, and your web application. Either user inserted an office add-in through the menu or it is added programmatically to a document, in both cases Office Application (Word/Excel/PowerPoint/OneNote/Project/Outlook) tries to get the manifest file from the specified location. This manifest file contains information about the add-in. For example: ID, name and description of the add-in and URL of the web application, etc.
Step 2: Office Application gets the URL of the web application and appends a query string “_host_Info” to the URL. This query parameter contains the information about the host.
- Host Application (Word, Excel etc.)
- Host Platform (Win32 etc.)
- Host Application version.
- Locale (en-US etc)
For example:
HTTPS://Your-ApplicationURL?_host_Info=Word$Win32$16.01$en-US
In some cases, pipe “|” is used as a separator instead of “$”.
Step 3: Loads the web application in the task pane.
Step 4: All the office Add-ins must reference “office.js” in their web application. Otherwise application won’t be able to communicate with the document. As the application loads “office.js” file, it will read the host info from the query string and loads the office API accordingly.
For example:
If your query string looks like: _host_Info=Word$Win32$16.01$en-US
Then office.js will load “word-win32-16.01.js”
Final Words
If you’re changing the URL at the time of the web application launch, make sure you’re not changing this query parameter or if you’re reconstructing the URL, include this query parameter. Failed to do so may cause a malfunction add-in. In a case of empty/nonexistent query parameter, “office.js” will load the default API.