Win32ole,从超链接而不是文本读取URL的方法? (Ruby,但不是必需的)
我正在使用 WIN32OLE 来读取一些处于各种混乱状态的数据文件。现在,我已经能够使用句子和形状方法从大多数文件中读取文本,但是,对于带有超链接的文件,我只能读取超链接文本,而不能读取底层 URL。
我一直在挖掘“超链接”的方法/ole_methods,并尝试了很多,但没有一个发布了除文本之外的超链接的任何属性(在某些情况下,适当地如此)。
irb(主):084:0> doc.Sentences(4).hyperlinks.inspect
<代码> => “#
irb(main):085:0> doc.Sentences(4).hyperlinks.text
<代码> => “嗨,我是一个链接!”
最相关的 Google 结果涉及使用“地址”标签(不是超链接的方法)向 Excel 添加链接。其他人提到“行动”,这似乎也不是一种方法。
I'm working with WIN32OLE to read some data files in various states of disarray. I've been able to read text from the majority of the files now using the Sentences and Shapes methods, however, for files with hyperlinks I am only able to read the hyperlink text, not the underlying URL.
I've been digging through the methods/ole_methods of 'hyperlinks' and have tried many, but none have released any properties of the hyperlink other than the text (appropriately so, in some cases).
irb(main):084:0> doc.Sentences(4).hyperlinks.inspect
=> "#<WIN32OLE:0x2c233d0>"
irb(main):085:0> doc.Sentences(4).hyperlinks.text
=> "Hi I'm a link!"
The most relevant google results deal with adding links to Excel, using the 'address' tag which is not a method of hyperlinks. Others reference 'action', which also does not seem to be a method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这对我有用:
编辑:我也用它来从文本框中获取链接。
无论显示文本如何,这两者都会给出完整的地址。
This works for me:
EDIT: I got this to work for grabbing the links out of TextBoxes too.
Both of these give the full address, regardless of the display text.
HyperLinks 对象是 HyperLink 对象的集合。
每个属性都包含一个应指向链接 URL 的“Address”属性和一个“textToDisplay”属性。
我对 ruby 或 win32ole lib 一无所知,但是您可以获取集合中的超链接对象吗,也许像这样:
The HyperLinks object is a collection of HyperLink objects.
Each one contains an "Address" property that should point to the URL of the link, and a "textToDisplay" property.
I don't know anything about ruby or the win32ole lib, but can you get to the Hyperlink objects in the collection, maybe like this: