Workbook Object (JavaScript API for Excel)

Workbook is the top level object which contains related workbook objects such as worksheets, tables, ranges, etc.

Properties

None

Relationships

Relationship Type Description Req. Set
application Application Represents Excel application instance that contains this workbook. Read-only. 1.1
bindings BindingCollection Represents a collection of bindings that are part of the workbook. Read-only. 1.1
functions Functions Represents Excel application instance that contains this workbook. Read-only. 1.2
names NamedItemCollection Represents a collection of workbook scoped named items (named ranges and constants). Read-only. 1.1
pivotTables PivotTableCollection Represents a collection of PivotTables associated with the workbook. Read-only. 1.3
settings SettingCollection Represents a collection of Settings associated with the workbook. Read-only. 1.4
tables TableCollection Represents a collection of tables associated with the workbook. Read-only. 1.1
worksheets WorksheetCollection Represents a collection of worksheets associated with the workbook. Read-only. 1.1

Methods

Method Return Type Description Req. Set
getSelectedRange() Range Gets the currently selected range from the workbook. 1.1

Method Details

getSelectedRange()

Gets the currently selected range from the workbook.

Syntax

workbookObject.getSelectedRange();

Parameters

None

Returns

Range

Examples

Excel.run(function (ctx) { 
    var selectedRange = ctx.workbook.getSelectedRange();
    selectedRange.load('address');
    return ctx.sync().then(function() {
            console.log(selectedRange.address);
    });
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});
tch(function(error) { console.log("Error: " + error); if (error instanceof OfficeExtension.Error) { console.log("Debug info: " + JSON.stringify(error.debugInfo)); } });

load(param: object)

Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

Syntax

object.load(param);

Parameters

Parameter Type Description  
param object Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object.  

Returns

void