如何取消vba followhyperlink?
我有一个带有一些超链接的 Excel 工作表。其中一些是电子邮件地址。
是否是电子邮件
当用户单击超链接时,我使用 Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
和 Target.Address like "mailto:*"
确定它 我现在想要的是取消默认的超链接行为并以编程方式自己打开电子邮件客户端。这样,我可以提供默认消息并添加附件。
我尝试使用 Cancel = True
但它不起作用。 我不想弄乱自定义超链接,因为 Excel 会自动生成电子邮件链接。
这可能吗?
打开超链接似乎发生在另一个线程上。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法阻止通过超链接进行点击。您可以通过在
Worksheet_FollowHyperlink
子项中设置断点来自行测试。 Excel 在执行代码之前点击链接。我看不到任何有助于干扰和阻止该行为的事件过程。
我可以给出的另一个提示是阻止 Excel 创建超链接 或通过带有 < 的 vba 来完成此操作代码>Worksheet_Change 事件。
接下来,您可以使用
Worksheet_SelectionChange
拦截一次点击,并检查单元格是否包含邮件地址。最后但并非最不重要的一点是,如果您确实知道电子邮件客户端是 Outlook,您可能可以获取新创建的邮件来添加附件、收件人、消息...
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...