使用 Ruby 将超链接添加到 Word 文档网中创建的书签
如何使用现有书签将超链接添加到 Word 文档。 我一直在使用 IRB 进行测试,但仍然出现命令失败。 我已附加到正在运行的 Word 应用程序,并选择了要绑定到超链接的文本。 为了进行测试,我一直在尝试添加一个谷歌超级链接。 我想一旦我明白了,我就能找到书签。 这是我正在使用的命令
doc.Hyperlink.add(word.selection, 'http://www.google.com', '','','text to display')
两个空白参数分别用于子地址和屏幕提示。
How do you add a Hyperlink to a word document using an existing bookmark. I have been testing using IRB but continue to get Command Failed.
I have attached to a running word application have text selected that I want to tie to the hyperlink. For testing I have been trying to just add a google hyperlnk. I figure once I get that then I would be able to figure out the bookmark. This is the command I am using
doc.Hyperlink.add(word.selection, 'http://www.google.com', '','','text to display')
The two blank parms are for SubAddress and ScreenTip respectivly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Luke-
你非常接近...
更改此......
至此...
有两个必要的更改:
(1) 您在超链接(复数)上调用 Add 方法集合,并且 (2) 第一个参数必须是 Range 对象。
通过这些更改,您的代码对我有用。
Luke-
You're very close...
Change this...
...to this...
There were two changes necessary:
(1) You call the Add method on the Hyperlinks (plural) collection, and (2) the first argument needs to be a Range object.
With these changes, your code works for me.