Share via


Workbook.SheetFollowHyperlink Event (2007 System)

Occurs when you click any hyperlink in a workbook.

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

Syntax

'Declaration
Public Event SheetFollowHyperlink As WorkbookEvents_SheetFollowHyperlinkEventHandler
'Usage
Dim instance As Workbook 
Dim handler As WorkbookEvents_SheetFollowHyperlinkEventHandler 

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

Examples

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.

This example is for a document-level customization.

Private ListBox1 As ListBox

Private Sub WorkbookSheetFollowHyperlink()
    ListBox1 = Globals.Sheet1.Controls.AddListBox( _
        Globals.Sheet1.Range("B2", "C3"), "listBox1")
End Sub 


Sub ThisWorkbook_SheetFollowHyperlink(ByVal Sh As Object, _
    ByVal Target As Excel.Hyperlink) Handles Me.SheetFollowHyperlink

    Dim sheet As Excel.Worksheet = CType(Sh, Excel.Worksheet)
    ListBox1.Items.Add(sheet.Name & ":" & Target.Address)
End Sub
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);
}

.NET Framework Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace