Udostępnij za pośrednictwem


WorkbookBase.SheetFollowHyperlink Event

Definition

Occurs when you click any hyperlink in a workbook.

public:
 event Microsoft::Office::Interop::Excel::WorkbookEvents_SheetFollowHyperlinkEventHandler ^ SheetFollowHyperlink;
public event Microsoft.Office.Interop.Excel.WorkbookEvents_SheetFollowHyperlinkEventHandler SheetFollowHyperlink;
member this.SheetFollowHyperlink : Microsoft.Office.Interop.Excel.WorkbookEvents_SheetFollowHyperlinkEventHandler 
Public Custom Event SheetFollowHyperlink As WorkbookEvents_SheetFollowHyperlinkEventHandler 

Event Type

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 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);
}
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

Applies to