共用方式為


Workbook.SheetFollowHyperlink 事件 (2007 系統)

更新:2007 年 11 月

當您按一下活頁簿中的任何超連結時發生。

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel.v9.0 (在 Microsoft.Office.Tools.Excel.v9.0.dll 中)

語法

Public Event SheetFollowHyperlink As WorkbookEvents_SheetFollowHyperlinkEventHandler

Dim instance As Workbook
Dim handler As WorkbookEvents_SheetFollowHyperlinkEventHandler

AddHandler instance.SheetFollowHyperlink, handler
public event WorkbookEvents_SheetFollowHyperlinkEventHandler SheetFollowHyperlink

範例

下列程式碼範例會示範 SheetFollowHyperlink 事件的處理常式。這個事件處理常式會在 ListBox 控制項中,保留目前的活頁簿中所有已經點選過的超連結,以及包含這些超連結的工作表名稱。

這是示範文件層級自訂的範例。

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

使用權限

請參閱

參考

Workbook 類別

Workbook 成員

Microsoft.Office.Tools.Excel 命名空間