创建超链接按钮 [英] Create Hyperlink button

查看:87
本文介绍了创建超链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个带有列的表,并可以添加超链接.

I would like to make a table with a collumn with the posibility to add a hyperlink.

用户应该能够按下按钮或显示添加超链接"的文字,然后弹出默认的超链接框.

The user should be able to push a button or text saying "Add hyperlink" and the default hyperlink box pops up.

这个possibel是否在excel中带有某种宏?

Is this possibel in excel with some sort of macro?

我试图记录宏并通过Internet搜索,但是找不到与我的问题类似的东西.而且,记录宏不会显示用于打开超链接框的代码,用户可以在其中选择要链接的地址.

I've tried to record macro and searching through the internet, but can't really find anything similar to my issue. And the record macro doesn't show the code for opening the hyperlink box where the user select what address to link.

推荐答案

您可以使用以下方式显示对话框:

You can display the dialog with:

If Application.Dialogs(xlDialogInsertHyperlink).Show Then
    'they pressed Ok
End If

这将为活动单元或形状创建一个超链接.它不会以任何其他方式返回超链接详细信息,因此您需要从例如它们所在的单元格中读取它:

This will create a Hyperlink for the active-cell, or a shape. It doesn't return the hyperlink details in any other way, so you'll need to read it from, for example, the cell they are in:

Dim hl As Hyperlink

If Application.Dialogs(xlDialogInsertHyperlink).Show Then
    'they pressed Ok
End If

Set hl = ActiveCell.Hyperlinks(1)

如果您实际上不需要单元格中的超链接,则可以随后将其删除(一旦您存储了所需的详细信息):

If you don't actually need the hyperlink in the cell then you can remove it afterwards (once you've stored its details that you need):

ActiveCell.Hyperlinks.Delete   'or, more likely,
ActiveCell.Clear

如果您只想显示对话框,而对对话框什么也不做,则Ctrl-K

If you simply want to display the dialog, and do nothing else with it, then Ctrl-K or

Application.SendKeys "^k"

或在快速访问工具栏"中添加插入超链接"按钮即可.

or adding the Insert Hyperlink button to the Quick Access Toolbar would do this.

这篇关于创建超链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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