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 命名空间