Export (0) Print
Expand All

WorksheetBase.FollowHyperlink Event

Occurs when you click any hyperlink on a worksheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public event DocEvents_FollowHyperlinkEventHandler FollowHyperlink

The following code example demonstrates a handler for the FollowHyperlink event that 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.

This example is for a document-level customization.

private ListBox listBox1;

private void WorksheetFollowHyperlink()
{
    listBox1 = this.Controls.AddListBox(
        this.Range["B2", "C3"], "listBox1");

    this.FollowHyperlink += 
        new Excel.DocEvents_FollowHyperlinkEventHandler(
        Worksheet1_FollowHyperlink);
}

void Worksheet1_FollowHyperlink(Excel.Hyperlink Target)
{
    listBox1.Items.Add(this.Name + ":" + Target.Address);
}

Show:
© 2014 Microsoft