Udostępnij za pośrednictwem


Worksheet.FollowHyperlink Event (2007 System)

Occurs when you click any hyperlink on a worksheet.

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

Syntax

'Declaration
Public Event FollowHyperlink As DocEvents_FollowHyperlinkEventHandler
'Usage
Dim instance As Worksheet 
Dim handler As DocEvents_FollowHyperlinkEventHandler 

AddHandler instance.FollowHyperlink, handler
public event DocEvents_FollowHyperlinkEventHandler FollowHyperlink
public:
 event DocEvents_FollowHyperlinkEventHandler^ FollowHyperlink {
    void add (DocEvents_FollowHyperlinkEventHandler^ value);
    void remove (DocEvents_FollowHyperlinkEventHandler^ value);
}
JScript does not support events.

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

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace