ExcelScript.RangeHyperlink interface

Represents the necessary strings to get/set a hyperlink (XHL) object.

Remarks

Examples

/**
 * This script puts a link to a webpage in a cell.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first cell in the current worksheet.
  const cell = workbook.getActiveWorksheet().getCell(0,0);

  // Create a link to a webpage.
  const sampleHyperlink : ExcelScript.RangeHyperlink = {
    address: "https://learn.microsoft.com/office/dev/scripts/resources/samples/table-of-contents",
    screenTip: "Sample: Create a workbook table of contents",
    textToDisplay: "Learn how to make a workbook table of contents"
  }

  // Put the link in the cell and format the width to fit.
  cell.setHyperlink(sampleHyperlink);
  cell.getFormat().autofitColumns();
}

Properties

address

Represents the URL target for the hyperlink.

documentReference

Represents the document reference target for the hyperlink.

screenTip

Represents the string displayed when hovering over the hyperlink.

textToDisplay

Represents the string that is displayed in the top left most cell in the range.

Property Details

Represents the URL target for the hyperlink.

address?: string;

Property Value

string

Represents the document reference target for the hyperlink.

documentReference?: string;

Property Value

string

Examples

/**
 * This script creates a hyperlink in the current cell to a table.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the selected cell.
  const selectedCell = workbook.getActiveCell();

  // Create a hyperlink from the current cell to a table named "Resources".
  const link : ExcelScript.RangeHyperlink = {
    documentReference: "Resources",
    screenTip: "Resources table",
    textToDisplay: "Go to table"
  } ;

  selectedCell.setHyperlink(link)
}

Represents the string displayed when hovering over the hyperlink.

screenTip?: string;

Property Value

string

Represents the string that is displayed in the top left most cell in the range.

textToDisplay?: string;

Property Value

string