Excel, ThisAddIn.vb: why is Application.SheetFollowHyperlink not called for =HYPERLINK()

后端 未结 1 1209
自闭症患者
自闭症患者 2021-01-26 07:36

I\'m trying to detect clicked hyperlinks in Excel. The Application.SheetFollowHyperlink Event claims that it will be called \"when you click any hyperlink in Microsoft Excel.\"<

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-26 08:17

    I seem to have solved the issue, although I'm not sure why the following works while the code I used above doesn't:

    Private HyperlinkFollower As Excel.DocEvents_FollowHyperlinkEventHandler
    
    Private Sub CalledWhenHyperlinkClicked(ByVal Target As Excel.Hyperlink)
        Dim w As Microsoft.Office.Interop.Excel.Window = Globals.ThisAddIn.Application.ActiveWindow
        MsgBox("hyperlink clicked")
    End Sub
    
    EventDel_HyperlinkFollower = New Excel.DocEvents_FollowHyperlinkEventHandler(AddressOf CalledWhenHyperlinkClicked)
    
    AddHandler worksheet.FollowHyperlink, EventDel_HyperlinkFollower
    

    0 讨论(0)
提交回复
热议问题