Office.initialize

Applies to: All add-in types
When the API is loaded and ready for the add-in to start interacting with user's content, it triggers the Office.initialize event.
An error will be generated if this event does not exist.
If your add-in includes more than one page, whenever it loads a new page that page must include or call an Office.initialize event handler.
This is run after both Office and your application are fully loaded.
This is put inside a self executing anonymous function.


( function () { 

   Office.initialize = function(reason) {
      $(document).ready(function () {
   
      });
   }

} ) ();


Reason Parameter

This can be used to identify how the add-in has been initialised.
There are two ways a task pane or content add-in can be initialized.
1 - The user has inserted it using Insert Add-in or from the Recently Used Add-ins list
2 - The user has opened a document that contains the add-in


The "reason" parameter provides access to the InitializationReason enumeration
The "reason" parameter is not required for Outlook Mail add-ins.

if (reason == Office.InitializationReason.Inserted) { 
    write("The add-in was just inserted/loaded.");
}

if (reason == Office.InitializationReason.DocumentOpened) {
    write("The add-in is already part of the document.");
}



© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

PrevNext