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
customXmlParts CustomXmlPartCollection Represents the collection of custom XML parts contained by this workbook. Read-only. 1.5
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
test Test For internal use only. Read-only. 1.6
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));
        }
});

results matching ""

    No results matching ""