Office Events

ObjectEventTypeRequirement SetDescription
CustomXMLPartNodeDeletedCustomXmlPartsRenamed in 1.1 from DataNodeDeleted
Word only
 NodeInsertedCustomXmlPartsRenamed in 1.1 from DataNodeInserted
Word only
 NodeReplacedCustomXmlPartsRenamed in 1.1 from DataNodeReplaced
Word only
RoamingSettings  Outlook only

All the above objects also have the following methods:

addHandlerAsync(eventType, handler [,Options], callback);

subscribes a handler to an event

removeHandlerAsync(eventType, handler [,Options], callback);

unsubscribes a handler from an event

eventType - An EventType enumeration. You can also use a text string "documentSelectionChanged"
handler - Either a named or anonymous inline function. You should always use a named function to allow it to be removed.
options - The only available parameter is asyncContxt
callback - The AsyncResult.value is always undefined

( function () { 

   Office.initialize = function (reason) {
      $(document).ready(function () {
   function event_onDocumentSelectionChanged(eventArgs) {
   // called when asynchronous operation completes
   // the eventArgs contains a reference to a DocumentSelectionChangedEvent Args object

   function callback_DocumentSelectionChanged(result) {
      var dataValue = result.value;

} ) ();

eventArgs Parameter

eventArgs.document - access the document that raises the event.

Event Scenarios

All events fall into one of the 4 different categories:
Office.initialize events
Document level selection change events
Bindinglevel selection and data change events
Settings changed events

<button onclick="myFunction(event)">Press This</button> 

function myFunction(event) {

Using JQuery

<button class="btn btn-default" id="myid">Press This</button> 

$('#myid').bind('click', myFunction);


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