简体   繁体   English

VBA Excel添加指向单词书签的超链接

[英]VBA Excel add hyperlink toward word bookmark

I need to create a hyperlink from VBA which would be placed in an Excel cell and pointing toward a Word Bookmark.我需要从 VBA 创建一个超链接,该超链接将放置在 Excel 单元格中并指向 Word 书签。

I know how to generate the hyperlink but when clicked, it doesn't bring me to the bookmark but to text similar to the bookmark's name.我知道如何生成超链接,但是当单击它时,它并没有将我带到书签,而是将我带到类似于书签名称的文本。 Please note that I've also tried to record a macro making my hyperlink but unfortunately it doesn't see any bookmark (might be a bug ?) the hyperlink created manually works.请注意,我也尝试录制一个宏来制作我的超链接,但不幸的是它没有看到任何书签(可能是错误?)手动创建的超链接有效。

Any help would be appreciated.任何帮助,将不胜感激。

Sheets("DevisTest").Range("G10")
.Hyperlinks.Add Anchor:=.Range("a1"), _
Address:="C:\Users\somepath\file.docx", _
SubAddress:="#thebookmark", _
ScreenTip:="description of what clicking will do", _
TextToDisplay:="Text displayed by the link"

Ike 's comment :艾克评论

You simply have to remove the hash from the SubAddress您只需从 SubAddress 中删除哈希

was right.是正确的。 I already tried it and had no success because there was a typography error in the bookmark name.我已经尝试过了,但没有成功,因为书签名称中存在排版错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM