Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelHyperlink

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

Links a cell, or every cell of a range or header column, to a URL or a place in the workbook.

Syntax

Examples

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 requiredposition: 0sets: Url, Internal
A1 address of the target cell.
-Display String optionalsets: Url, Internal
Optional display text.
-DisplayMode ExcelHyperlinkDisplay optionalsets: Url
Selects original text, full URL, host name or smart hyperlink display.
Possible values: Text, Url, Host, Smart
-Document ExcelDocument optionalpipeline: True (ByValue)
Caller-owned workbook; omission uses the enclosing Excel content block.
-NoStyle SwitchParameter optional
Skip hyperlink styling (blue + underline).
-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.
-Url String requiredposition: 1sets: Url
External URL to link to.
-TargetAddress String required in Internalsets: Internal, InternalRange, InternalHeader
Target A1 address for internal links.
-TargetSheet OfficeSheetSelector optionalsets: Internal
Target worksheet name for internal links.
-DisplayScript ScriptBlock optionalsets: InternalRange, InternalHeader, UrlRange, UrlHeader
Optional mapping from cell text to display text.
-Internal SwitchParameter requiredsets: InternalRange, InternalHeader
Uses worksheet destinations instead of external URLs for header-based links.
-Range String required in InternalRange, UrlRangeposition: 0sets: InternalRange, InternalHeader, UrlRange, UrlHeader
A1 cell range on the selected worksheet.
-TargetSheetScript ScriptBlock optionalsets: InternalRange, InternalHeader
Script that maps each source cell text to a destination worksheet name.
-Header String requiredposition: 0sets: InternalHeader, UrlHeader
Header text identifying the target column.
-Table String optionalsets: InternalHeader, UrlHeader
Native Excel table used to resolve the source range or header.
-UrlScript ScriptBlock requiredsets: UrlRange, UrlHeader
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.