Excel.AllowEditRange class

Represents an AllowEditRange object found in a worksheet. This object works with worksheet protection properties. When worksheet protection is enabled, an AllowEditRange object can be used to allow editing of a specific range, while maintaining protection on the rest of the worksheet.

Extends

Remarks

[ API set: ExcelApiOnline 1.1 ]

Properties

address

Specifies the range associated with the object. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, this method throws an AccessDenied error and fails to set the range.

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

isPasswordProtected

Specifies if the object is password protected.

title

Specifies the title of the object. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, this method throws an AccessDenied error and fails to set the title. If there is already an existing AllowEditRange with the same string, or if the string is null or empty (""), then this method throws an InvalidArgument error and fails to set the title.

Methods

delete()

Deletes the object from the AllowEditRangeCollection. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, this method throws an AccessDenied error and fails the delete operation.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

pauseProtection(password)

Pauses worksheet protection for the object for the user in the current session. This method does nothing if worksheet protection isn't enabled or is already paused. If worksheet protection cannot be paused, this method throws an UnsupportedOperation error and fails to pause protection for the object. If the password is incorrect, then this method throws a BadPassword error and fails to pause protection for the object. If a password is supplied but the object does not require a password, the inputted password will be ignored and the operation will succeed.

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

setPassword(password)

Changes the password associated with the object. Setting the password string as empty ("") or null will remove password protection from the object. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, then this method throws an AccessDenied error and the set operation fails.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.AllowEditRange object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.AllowEditRangeData) that contains shallow copies of any loaded child properties from the original object.

Property Details

address

Specifies the range associated with the object. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, this method throws an AccessDenied error and fails to set the range.

address: string;

Property Value

string

Remarks

[ API set: ExcelApiOnline 1.1 ]

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

isPasswordProtected

Specifies if the object is password protected.

readonly isPasswordProtected: boolean;

Property Value

boolean

Remarks

[ API set: ExcelApiOnline 1.1 ]

title

Specifies the title of the object. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, this method throws an AccessDenied error and fails to set the title. If there is already an existing AllowEditRange with the same string, or if the string is null or empty (""), then this method throws an InvalidArgument error and fails to set the title.

title: string;

Property Value

string

Remarks

[ API set: ExcelApiOnline 1.1 ]

Method Details

delete()

Deletes the object from the AllowEditRangeCollection. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, this method throws an AccessDenied error and fails the delete operation.

delete(): void;

Returns

void

Remarks

[ API set: ExcelApiOnline 1.1 ]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: Excel.Interfaces.AllowEditRangeLoadOptions): Excel.AllowEditRange;

Parameters

options
Excel.Interfaces.AllowEditRangeLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Excel.AllowEditRange;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Excel.AllowEditRange;

Parameters

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

pauseProtection(password)

Pauses worksheet protection for the object for the user in the current session. This method does nothing if worksheet protection isn't enabled or is already paused. If worksheet protection cannot be paused, this method throws an UnsupportedOperation error and fails to pause protection for the object. If the password is incorrect, then this method throws a BadPassword error and fails to pause protection for the object. If a password is supplied but the object does not require a password, the inputted password will be ignored and the operation will succeed.

pauseProtection(password?: string): void;

Parameters

password

string

The password associated with the AllowEditRange object.

Returns

void

Remarks

[ API set: ExcelApiOnline 1.1 ]

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.AllowEditRangeUpdateData, options?: OfficeExtension.UpdateOptions): void;

Parameters

properties
Excel.Interfaces.AllowEditRangeUpdateData

A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

Provides an option to suppress errors if the properties object tries to set any read-only properties.

Returns

void

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Excel.AllowEditRange): void;

Parameters

Returns

void

setPassword(password)

Changes the password associated with the object. Setting the password string as empty ("") or null will remove password protection from the object. Worksheet protection must be disabled or paused for this method to work properly. If worksheet protection is enabled and not paused, then this method throws an AccessDenied error and the set operation fails.

setPassword(password?: string): void;

Parameters

password

string

The password associated with the AllowEditRange object.

Returns

void

Remarks

[ API set: ExcelApiOnline 1.1 ]

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.AllowEditRange object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.AllowEditRangeData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Excel.Interfaces.AllowEditRangeData;

Returns