Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Office.InitializationReason enum
- Package:
- office
Specifies whether the add-in was just inserted or was already contained in the document.
Remarks
Used by
Examples
// You can use the value of the InitializationEnumeration to implement different logic for
// when the add-in is first inserted versus when it is already part of the document.
// The following example shows some simple logic that uses the value of the reason parameter
// to display how the task pane or content add-in was initialized.
Office.initialize = function (reason) {
// Checks for the DOM to load using the jQuery ready method.
$(document).ready(function () {
// After the DOM is loaded, code specific to the add-in can run.
// Display initialization reason.
if (reason === Office.InitializationReason.Inserted) {
write("The add-in was just inserted.");
}
if (reason === Office.InitializationReason.DocumentOpened) {
write("The add-in is already part of the document.");
}
});
}
// Function that writes to a div with id='message' on the page.
function write(message) {
document.getElementById('message').innerText += message;
}
Fields
| DocumentOpened | The add-in is already part of the document that was opened. |
| Inserted | The add-in was just inserted into the document. |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Add-ins
Feedback
Was this page helpful?
