Worksheet_FollowHyperlink and MsgBox not working in Excel 2010

匆匆过客 提交于 2019-12-02 00:29:38

问题


Cell A1:

=HYPERLINK("#Sheet2!a2","link")

Sheet->View Code

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox ("hello")
End Sub

MessageBox does not open when I left click on A1; instead, #Sheet2!a2 opens. To further complicate matters,

Sheet->View Code

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
MsgBox ("hello")
End Sub

Right clicking on the cell with the hyperlink does fire the message box, but google fires anyway.

Sheet->View Code

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
MsgBox ("hello")
End Sub

Now double clicking A1 does not generate a message box.

Why?


回答1:


Well that's a new one on me, but in both 2003 and 2010 the FollowHyperlink event is not fired for cells that contain the HYPERLINK() function. Both versions fire for native hyperlinks.

It looks like the SelectionChange event fires, so you could test that there's a hyperlink in the cell or whatever other tests you need.



来源:https://stackoverflow.com/questions/9828260/worksheet-followhyperlink-and-msgbox-not-working-in-excel-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!