Event - ActiveViewChanged

getActiveViewAsyncM(PowerPoint only) Returns the state of the current view of the presentation (edit or read). 
getFileAsyncMUpdated in 1.1 to get the document as PDF with add-ins for PowerPoint and Word.
(fileType [,options] [,callback])
Supports PDF file type
getFilePropertiesAsyncM(Added 2013, SP1) Gets file properties of the current document. 
getMaxResourceIndexAsyncM(Project only) 
getMaxTaskIndexAsyncM(Project only) 
getProjectFieldAsyncM(Project only) 
getResourceByIndexAsyncM(Project only) 
getResourceFieldAsyncM(Project only) 
getSelectedDataAsyncMReads the data contained in the current selection in the document. 
getSelectedResourceAsyncM(Project only) 
getSelectedTaskAsyncM(Project only) 
getSelectedViewAsyncM(Project only) 
getTaskAsyncM(Project only) 
getTaskByIndexAsyncM(Project only) 
getTaskFieldAsyncM(Project only) 
getWSSUrlM(Project only) 
goToByIdAsyncM(Added 2013, SP1) Named Ranges 
removeHandlerAsyncM(eventType [,options] [,callback]) 
setResourceFieldAsyncM(Project only) 
setSelectedDataAsyncM(data [,options] [,callback(asyncResult)]) 
setTaskFieldAsyncM(Project only) 

Current Selection

The document object exposes two methods that lets you read and write to the current selection in a spreadsheet or document.
getSelectedDataAsync and setSelectedDataAsync

Read from Current Selection

Read a matrix from the current selection in the document and display its contents

                                             function (asyncResult) {
  if (asyncResult.status == "failed") {
    showMessage("Action failed with error: " + asyncResult.error.message);
  else {
    showMessage("Selected data: " + asyncResult.value);

The following example uses the getSelectedDataAsync method to read the currently selected range of cells. To specify that the selection is read as a range of cells, specify the coerctionType parameter as CoercionType.Matrix. The callback function returns an object containing the data currently selected by the user, which can use the asyncResult.value property to access the data.

Write to Current Selection

var myMatrix = [["1","2","3"],["4","5","6"],["7","8","9"]]; 

// Set myMatrix in the document.
                                             function (asyncResult) {
  if (asyncResult.status == "failed") {
    showMessage("Action failed with error: " + asyncResult.error.message);

Be aware that a matrix can only be written into the spreadsheet if no other data in the surrounding cells will be overwritten.

Matrix or Table type ?
If your data has a heading row then you must use Table
If you need your data to grow dynamically when rows and columns are added then you must use Table
Adding rows and columns in supported in Matrix but appending is only supported in Table

Detecting Changes in the Current Selection

You can detect changes in the selection by adding an event handler for the SelectionChanged event
You can either pass the enumeration or a text string "documentSelectionChanged"

                                             function (asyncResult) {}

// Event Handler Function
function myHandlerName(eventArgs){
   write('Document Selection Changed');

// Function that writes to a div with id='message' on the page
function write(message){
   document.getElementById('message').innerText += message;

The argument passed to the event handler contains a reference to a DocumentSelectionChangedEventArgs object which can be used to access the document that raised the event

Stop Detection Changes in Selection

You can stop listening to events by removing the handler


© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext