This documentation is archived and is not being maintained.

Workbook.SheetFollowHyperlink Event

Occurs when you click any hyperlink in a workbook.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public event WorkbookEvents_SheetFollowHyperlinkEventHandler SheetFollowHyperlink

The following code example demonstrates a handler for the SheetFollowHyperlink event. The event handler keeps a list of all the hyperlinks in the current workbook that have been clicked, plus the names of the worksheets that contain these hyperlinks, in a ListBox control.

private ListBox listBox1;

private void WorkbookSheetFollowHyperlink()
{
    listBox1 = Globals.Sheet1.Controls.AddListBox(
        Globals.Sheet1.Range["B2", "C3"], "listBox1");

    this.SheetFollowHyperlink +=
        new Excel.WorkbookEvents_SheetFollowHyperlinkEventHandler(
        ThisWorkbook_SheetFollowHyperlink);
}

void ThisWorkbook_SheetFollowHyperlink(object Sh,
    Excel.Hyperlink Target)
{
    Excel.Worksheet sheet = (Excel.Worksheet)Sh;
    listBox1.Items.Add(sheet.Name + ":" + Target.Address);
}

Show: