Cmdlet
Set-OfficeExcelValidation
Sets prompt and error messages on existing validation rules.
Syntax
Set-OfficeExcelValidation
[-Document <ExcelDocument>]
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-PassThru]
[-Prompt <String>]
[-PromptTitle <String>]
[[-Range] <String>]
[-Sheet <OfficeSheetSelector>]
[-ShowErrorMessage]
[-ShowInputMessage]
[<CommonParameters>]#Parameter set:
RangeSet-OfficeExcelValidation
[-Document <ExcelDocument>]
[-ErrorMessage <String>]
[-ErrorTitle <String>]
-Header <String>
[-HeaderRow <Int32>]
[-IncludeHeader]
[-PassThru]
[-Prompt <String>]
[-PromptTitle <String>]
[-Sheet <OfficeSheetSelector>]
[-ShowErrorMessage]
[-ShowInputMessage]
[-Table <String>]
[<CommonParameters>]#Parameter set:
HeaderExamples
Add an input prompt
Open-OfficeExcel -Path .\Reports\Helpdesk.xlsx {
ExcelSheet 'Tickets' {
Set-OfficeExcelValidation -Header Priority -Table Tickets -PromptTitle 'Priority' -Prompt 'P1 is a production outage; P4 is a question.' -ShowInputMessage
}
}Shows a hint when someone selects a cell in the Priority column.
Reword error messages across a form
Open-OfficeExcel -Path .\Forms\Equipment-Requests.xlsx {
ExcelSheet 'Requests' {
Set-OfficeExcelValidation -Range E2:E500 -ErrorTitle 'Cost centre' -ErrorMessage 'Pick a cost centre from the list. Ask Finance if yours is missing.' -ShowErrorMessage
}
}Replaces the generic error text of the cost-centre rule in an existing form with guidance for the requester.
Parameters
- -Document ExcelDocument
- Caller-owned workbook; omission uses the enclosing Excel content block.
- -ErrorMessage String
- Error message text. Omit or pass null to clear the message.
- -ErrorTitle String
- Error title. Omit or pass null to clear the title.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Prompt String
- Input prompt text. Omit or pass null to clear the prompt.
- -PromptTitle String
- Input prompt title. Omit or pass null to clear the title.
- -Range String
- A1 cell range on the selected worksheet.
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
- -ShowErrorMessage SwitchParameter
- Forces Excel to show the validation error.
- -ShowInputMessage SwitchParameter
- Forces Excel to show the input prompt.
- -Header String
- Header text identifying the target column.
- -HeaderRow Int32
- One-based row containing the column headers.
- -IncludeHeader SwitchParameter
- Includes the header cell in the resolved column range.
- -Table String
- Native Excel table used to resolve the source range or header.
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.