共用方式為


WorkbookBase.SheetFollowHyperlink 事件

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

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

語法

'宣告
Public Event SheetFollowHyperlink As WorkbookEvents_SheetFollowHyperlinkEventHandler
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);
}

.NET Framework 安全性

請參閱

參考

WorkbookBase 類別

Microsoft.Office.Tools.Excel 命名空間