Office API

An Office web add-in is a web application hosted inside a browser control that runs inside an Office application (desktop and online).
Add-ins can access information in the current document and connect to web services and other web-based resources.
An add-in is not installed on the host but has its implementation hosted on a web server.
This type of add-in uses standard web technologies like HTML5, XML, CSS3, JavaScript and REST APIs.
The JavaScript API has a common object model (or Shared API) that is shared across the different application.
The JavaScript API also has host-specific object models.
These types of add-ins have two distinct parts, a Manifest and a Web Page.
JavaScript is a single-threaded language


Documentation

https://docs.microsoft.com/en-us/office/dev/add-ins/


Office Runtime

Office add-ins are controlled by a specific runtime.
This runtime controls permissions as well as performance
This runtime protects the user experience
This runtime prevents any modal interactions
This runtime prevents any direct access to the host applications UI thread
This runtime isolates the process the app run in
This runtime manages the app lifecycle and interoperability between the app and the client host


Microsoft.Office.WebExtension

Your add-in must include a reference to the Office.js JavaScript library.
This library enables you to access the Microsoft.Office.WebExtensions namespace.
The office.js library is a script loader that loads the object model corresponding to the office application.
This provides access to the Office top level object that represents an instance of an add-in.
The alias name "Office" is automatically defined to allow easy access to this namespace.


Office.context - represents the runtime environment of the add-in
Office.initialize - this event occurs when the runtime environment is loaded and ready exposing a callback function
Office.select - allows support for the promises pattern for working with existing binding objects (getDataAsync, setDataAsync, addHandlerAsync, removeHandlerAsync)
var = office.context.displayLanguage
var = office.context.contentLanguage


Add-in Initialisation

When a supported add-in starts, it reads the XML manifest
For Excel, Word, PowerPoint and Project the add-in loads when a document is opened or the add-in is inserted making the UI visible.
For Outlook whenever the context satsifies the activation of an add-in, then the UI is visible
The Office application opens the HTML page in a browser control (or an iFrame if it's a web application). The browser control uses Internet Explorer 9 components and security.
The OnLoad event is called
The office add-in framework calls the event handler for the initialize event of the Office object
When the HTML finishes loading the add-in finishes initializing and the main functionality can proceed



© 2018 Better Solutions Limited. All Rights Reserved. © 2018 Better Solutions Limited TopNext