Share via


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)

Syntax

'Declaration
Public Event FollowHyperlink As DocEvents_FollowHyperlinkEventHandler
public event DocEvents_FollowHyperlinkEventHandler FollowHyperlink

Examples

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 listBox1 As ListBox
Private Sub WorksheetFollowHyperlink()
    listBox1 = Me.Controls.AddListBox(Me.Range("B2", "C3"), _
        "listBox1")
End Sub 

Sub Worksheet1_FollowHyperlink(ByVal Target As Excel.Hyperlink) _
    Handles Me.FollowHyperlink
    listBox1.Items.Add(Me.Name & ":" & Target.Address)
End Sub
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);
}

.NET Framework Security

See Also

Reference

WorksheetBase Class

Microsoft.Office.Tools.Excel Namespace