Cmdlet
Set-OfficeExcelHyperlink
Links a cell, or every cell of a range or header column, to a URL or a place in the workbook.
Syntax
Set-OfficeExcelHyperlink
[-Address] <String>
[-Display <String>]
[-DisplayMode <Text| Url| Host| Smart>]
[-Document <ExcelDocument>]
[-NoStyle]
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[-Url] <String>
[<CommonParameters>]#Parameter set:
UrlSet-OfficeExcelHyperlink
[-Address] <String>
[-Display <String>]
[-Document <ExcelDocument>]
[-NoStyle]
[-PassThru]
[-Sheet <OfficeSheetSelector>]
-TargetAddress <String>
[-TargetSheet <OfficeSheetSelector>]
[<CommonParameters>]#Parameter set:
InternalSet-OfficeExcelHyperlink
[-DisplayScript <ScriptBlock>]
[-Document <ExcelDocument>]
-Internal
[-NoStyle]
[-PassThru]
[-Range] <String>
[-Sheet <OfficeSheetSelector>]
[-TargetAddress <String>]
[-TargetSheetScript <ScriptBlock>]
[<CommonParameters>]#Parameter set:
InternalRangeSet-OfficeExcelHyperlink
[-DisplayScript <ScriptBlock>]
[-Document <ExcelDocument>]
[-Header] <String>
-Internal
[-NoStyle]
[-PassThru]
[-Range <String>]
[-Sheet <OfficeSheetSelector>]
[-Table <String>]
[-TargetAddress <String>]
[-TargetSheetScript <ScriptBlock>]
[<CommonParameters>]#Parameter set:
InternalHeaderSet-OfficeExcelHyperlink
[-DisplayScript <ScriptBlock>]
[-Document <ExcelDocument>]
[-NoStyle]
[-PassThru]
[-Range] <String>
[-Sheet <OfficeSheetSelector>]
-UrlScript <ScriptBlock>
[<CommonParameters>]#Parameter set:
UrlRangeSet-OfficeExcelHyperlink
[-DisplayScript <ScriptBlock>]
[-Document <ExcelDocument>]
[-Header] <String>
[-NoStyle]
[-PassThru]
[-Range <String>]
[-Sheet <OfficeSheetSelector>]
[-Table <String>]
-UrlScript <ScriptBlock>
[<CommonParameters>]#Parameter set:
UrlHeaderExamples
Link a cell to a web page
Open-OfficeExcel -Path .\Reports\Status.xlsx {
ExcelSheet 'Summary' {
ExcelHyperlink A2 'https://status.example.com' -Display 'Service status'
}
}Turns A2 into a link to the status page with readable text.
Link every ticket number to the helpdesk
Open-OfficeExcel -Path .\Reports\Helpdesk.xlsx {
ExcelSheet 'Tickets' {
ExcelHyperlink -Header Ticket -Table Tickets -UrlScript { param($text) "https://helpdesk.example.com/tickets/$text" }
}
}Links each value in the Ticket column of the Tickets table to its page in the helpdesk system.
Link a summary to the detail sheets
$servers = 'SQL01', 'SQL02', 'WEB01'
Open-OfficeExcel -Path .\Reports\Disk-Capacity.xlsx {
ExcelSheet 'Summary' {
ExcelHyperlink -Header Server -Internal
}
foreach ($server in $servers) {
ExcelSheet $server {
ExcelHyperlink H1 -TargetSheet Summary -TargetAddress A1 -Display 'Back to summary'
}
}
}Links each server name in the Summary sheet to the sheet of the same name, and adds a link back to the summary on every server sheet.
Parameters
- -Address String
- A1 address of the target cell.
- -Display String
- Optional display text.
- -DisplayMode ExcelHyperlinkDisplay
- Selects original text, full URL, host name or smart hyperlink display.
- Possible values:
Text,Url,Host,Smart - -Document ExcelDocument
- Caller-owned workbook; omission uses the enclosing Excel content block.
- -NoStyle SwitchParameter
- Skip hyperlink styling (blue + underline).
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
- -Url String
- External URL to link to.
- -TargetAddress String
- Target A1 address for internal links.
- -TargetSheet OfficeSheetSelector
- Target worksheet name for internal links.
- -DisplayScript ScriptBlock
- Optional mapping from cell text to display text.
- -Internal SwitchParameter
- Uses worksheet destinations instead of external URLs for header-based links.
- -Range String
- A1 cell range on the selected worksheet.
- -TargetSheetScript ScriptBlock
- Script that maps each source cell text to a destination worksheet name.
- -Header String
- Header text identifying the target column.
- -Table String
- Native Excel table used to resolve the source range or header.
- -UrlScript ScriptBlock
- Maps the cell text to a URL.
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.