Cmdlet
Set-OfficeExcelDataValidationMessage
Sets prompt and error messages on existing Excel data validation rules.
Syntax
Set-OfficeExcelDataValidationMessage
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-HeaderName <String>]
[-HeaderRow <Int32>]
[-IncludeHeader]
[-PassThru]
[-Prompt <String>]
[-PromptTitle <String>]
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ShowErrorMessage]
[-ShowInputMessage]
[-TableName <String>]
[<CommonParameters>]#Parameter set:
ContextSet-OfficeExcelDataValidationMessage
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-HeaderName <String>]
[-HeaderRow <Int32>]
[-IncludeHeader]
[-PassThru]
[-Path] <String>
[-Prompt <String>]
[-PromptTitle <String>]
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ShowErrorMessage]
[-ShowInputMessage]
[-TableName <String>]
[<CommonParameters>]#Parameter set:
PathSet-OfficeExcelDataValidationMessage
-Document <ExcelDocument>
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-HeaderName <String>]
[-HeaderRow <Int32>]
[-IncludeHeader]
[-PassThru]
[-Prompt <String>]
[-PromptTitle <String>]
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ShowErrorMessage]
[-ShowInputMessage]
[-TableName <String>]
[<CommonParameters>]#Parameter set:
DocumentExamples
Add prompt and error text to a validation rule.
$rules = Set-OfficeExcelDataValidationMessage -Path .\Report.xlsx -Sheet Data -HeaderName Sales -TableName ServiceHealth -PromptTitle 'Sales' -Prompt 'Enter 1-1000' -ErrorTitle 'Invalid sales' -ErrorMessage 'Enter a whole number from 1 to 1000' -ShowInputMessage -ShowErrorMessage -PassThru
$rules |
Select-Object Range, PromptTitle, ErrorTitleUpdates validation metadata for matching rules and saves the workbook.
Parameters
- -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.
- -HeaderName String
- Header or table column name used to resolve the validation rules to update.
- -HeaderRow Int32
- Worksheet header row used when resolving HeaderName without a table. Use 0 for the first row of the used range.
- -IncludeHeader SwitchParameter
- Include the header cell in the resolved range.
- -PassThru SwitchParameter
- Returns matching validation rules after updating them.
- -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 range used to select existing validation rules.
- -Sheet String
- Worksheet name to update. Defaults to the current DSL sheet.
- -SheetIndex Int32
- Worksheet index (0-based) to update. Defaults to the current DSL sheet.
- -ShowErrorMessage SwitchParameter
- Forces Excel to show the validation error.
- -ShowInputMessage SwitchParameter
- Forces Excel to show the input prompt.
- -TableName String
- Optional table name for header-based range resolution.
- -Path String
- Workbook path to update.
- -Document ExcelDocument
- Workbook to update outside the DSL context.
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.