Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Set-OfficeExcelNamedRange

Aliases: ExcelNamedRange
Module
PSWriteOffice
Aliases
ExcelNamedRange
Inputs
OfficeIMO.Excel.ExcelDocument

Creates or updates a named range.

Syntax

Set-OfficeExcelNamedRange
[-Global]
[-Hidden]
[-Name] <String>
[-PassThru]
[-Range] <String>
[-Save]
[-ValidationMode <Sanitize|Strict>]
[<CommonParameters>]
#
Parameter set: Context
Set-OfficeExcelNamedRange
-Document <ExcelDocument>
[-Hidden]
[-Name] <String>
[-PassThru]
[-Range] <String>
[-Save]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ValidationMode <Sanitize|Strict>]
[<CommonParameters>]
#
Parameter set: Document

Description

Defaults to the current sheet scope when used inside the Excel DSL.

Examples

Define a named range inside a sheet.

ExcelSheet 'Data' { Set-OfficeExcelNamedRange -Name 'Totals' -Range 'B2:B50' }

Creates a sheet-scoped name for the range.

Parameters

-Global SwitchParameter optionalsets: Context
Force a workbook-global name even inside a sheet block.
-Hidden SwitchParameter optional
Mark the defined name as hidden.
-Name String requiredposition: 0
Name of the defined range.
-PassThru SwitchParameter optional
Emit the name after creation.
-Range String requiredposition: 1
Range in A1 notation.
-Save SwitchParameter optional
Save the workbook immediately after setting the name.
-ValidationMode ExcelDefinedNameValidationMode optional
Validate or sanitize the defined name.
Possible values: Sanitize, Strict
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to operate on outside the DSL context.
-Sheet String optionalsets: Document
Worksheet name when using Document.
-SheetIndex Int32 optionalsets: Document
Worksheet index (0-based) when using Document.

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.