Office Events
Object | EventType | Requirement Set | Description |
CustomXMLPart | NodeDeleted | CustomXmlParts | Renamed in 1.1 from DataNodeDeleted Word only |
NodeInserted | CustomXmlParts | Renamed in 1.1 from DataNodeInserted Word only | |
NodeReplaced | CustomXmlParts | Renamed in 1.1 from DataNodeReplaced Word only | |
Document | ActiveViewChanged | DocumentEvents | |
SelectionChanged | DocumentEvents | ||
MatrixBinding | BindingSelectionChanged | MatrixBindings | |
BindingDataChanged | MatrixBindings | ||
TableBinding | BindingSelectionChanged | TableBindings | |
BindingDataChanged | TableBindings | ||
TextBinding | BindingSelectionChanged | TextBindings | |
BindingDataChanged | TextBindings | ||
Settings | ActiveViewChanged | Settings | |
SettingsChanged | Settings | ||
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 () {
Office.context.document.addHandlerAsync(
Office.EventType.DocumentSelectionChanged,
event_onDocumentSelectionChanged,
callback_DocumentSelectionChanged
);
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.binding
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);
$('#myid').click(myFunction);
$('#myid').on('click',myFunction);
window
onload
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopNext