Skip to main content

AddUser

Sets a user to the current protected range.

Syntax

expression.AddUser(sId, sName, protectedRangeUserType);

expression - A variable that represents a ApiProtectedRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sIdRequiredstringThe user ID.
sNameRequiredstringThe user name.
protectedRangeUserTypeRequiredProtectedRangeUserTypeThe user type of the protected range.

Returns

ApiProtectedRangeUserInfo | null

Example

This example adds the the user for protected range.

// How to open an access for the protected range to user specifing user id, name and access type.

// Get an active sheet, add protected range to it and add user with rights.

let worksheet = Api.GetActiveSheet();
worksheet.AddProtectedRange("protectedRange", "$A$1:$B$1");
let protectedRange = worksheet.GetProtectedRange("protectedRange");
protectedRange.AddUser("userId", "name", "CanView");