在VBA中创建超链接

时间:2018-07-09 15:53:22

标签: vba word-vba

我想在VBA单词中的两个书签之间创建超链接。这是我想出的代码,出现类型不匹配错误,不确定为什么

ActiveDocument.Hyperlinks.Add 
Anchor:=ActiveDocument.Bookmarks("TableOfContents_KeyBenefits"), _
Address:=ActiveDocument.Bookmarks, SubAddress:="KeyBenefitsTarget"

1 个答案:

答案 0 :(得分:2)

ActiveDocument.Hyperlinks.Add _
     Anchor:=ActiveDocument.Bookmarks("TableOfContents_KeyBenefits").Range, _
     Address:=ActiveDocument.FullName, SubAddress:="KeyBenefitsTarget"