如何取消vba followhyperlink? [英] how to cancel the vba followhyperlink?

查看:259
本文介绍了如何取消vba followhyperlink?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个excel工作表与一些超链接。其中一些是电子邮件地址。

当用户单击超链接时,我确定是否是电子邮件,使用 Worksheet_FollowHyperlink(ByVal Target As Hyperlink) Target.Address,如mailto:*



我现在想要的是 em>取消默认超链接行为 ,并以编程方式自己打开电子邮件客户端。这样,我可以提供一个默认消息并添加附件。



我尝试使用 Cancel = True 不工作
我不想混淆自定义超链接,因为excel会自动生成链接到电子邮件。



是否可以?

打开超链接似乎在另一个线程上发生。

解决方案

无法阻止点击超链接。您可以通过在 Worksheet_FollowHyperlink sub中设置断点来自己测试。 Excel遵循执行代码之前的链接。



看不到有助于干扰的任何事件过程并阻止行为。



我可以给的另一个提示是阻止Excel创建超链接,或者通过vba使用 Worksheet_Change 事件来执行。

接下来,您可以拦截一个peuso-点击 Worksheet_SelectionChange 并检查单元格是否包含邮件地址。



最后但并非最不重要的,如果你知道电子邮件客户端是Outlook ,您可能会得到新创建的邮件添加附件,收件人,邮件...


I have an excel worksheet with some hyperlinks. Some of them are email addresses.
When a user clicks a hyperlink, I determine whether or not it is an email, using Worksheet_FollowHyperlink(ByVal Target As Hyperlink) and Target.Address like "mailto:*"

What I want now is to cancel the default hyperlink behavior and open the email client myself, programmatically. That way, I can provide a default message and add attachments.

I tried using Cancel = True but it doesn't work. I prefer not to mess with custom hyperlinks because excel generates links to email automatically.

Is it even possible?
Opening the hyperlink seems to happen on another thread.

解决方案

You cannot prevent a click from following the hyperlink. You can test by yourself by setting a breakpoint in the Worksheet_FollowHyperlink sub. Excel follow the link before executing the code.

I can't see any event procedure that would help interfere and prevent the behavior.

Another tip i could give is to prevent Excel from creating hyperlinks or to do it by vba with a Worksheet_Change event.
Next, you could intercept a peuso-click with a Worksheet_SelectionChange and check if the cell contains a mail address.

Last but not least, if you do know that the e-mail client is Outlook, you can probably get the newly created mail to add attachments, recipients, message...

这篇关于如何取消vba followhyperlink?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆