Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Unprotect-OfficeExcelSheet

Module
PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument

Removes worksheet protection.

Syntax

Unprotect-OfficeExcelSheet
[-Document <ExcelDocument>]
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]
#
Parameter set: Default

Examples

Remove sheet protection

Open-OfficeExcel -Path .\Finance\Pricing-Model.xlsx {
    Unprotect-OfficeExcelSheet -Sheet Inputs
}

Unprotects the Inputs sheet.

Update a protected sheet and protect it again

Open-OfficeExcel -Path .\Finance\Pricing-Model.xlsx {
    ExcelSheet 'Rates' {
        Unprotect-OfficeExcelSheet
        ExcelCell B2 1.09
        ExcelCell B3 0.86
        Protect-OfficeExcelSheet -AllowSort
    }
}

Unprotects the price sheet, writes the new rates and restores protection with sorting allowed.

Parameters

-Document ExcelDocument optionalpipeline: True (ByValue)
Caller-owned workbook; omission uses the enclosing Excel content block.
-PassThru SwitchParameter optional
Emits the native result after the operation.
-Sheet OfficeSheetSelector optional
Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.