我正在使用的文档中充满了Endnote制作的内部超链接,其中包含“#ENREF_76”作为地址。我正在尝试编写一个循环遍历所有超链接的宏,将文本复制到链接中的地址并对其进行处理。像:
For i = ActiveDocument.Hyperlinks.Count To 1 Step -1
With ActiveDocument.Hyperlinks(i)
myText = .get_The_Text_At_The_Address_In_The_Link
doStuff(myText)
End With
Next i
这甚至可能吗?
答案 0 :(得分:0)
我对Word并不熟悉,但是如果您的链接书签实际上包含您要抓取的文本,这将会有效。
Sub Tester()
Dim h As Hyperlink, b As Bookmark
For Each h In ActiveDocument.Hyperlinks
'Debug.Print h.TextToDisplay, h.SubAddress
On Error Resume Next
Set b = ActiveDocument.Bookmarks(h.SubAddress)
On Error GoTo 0
If Not b Is Nothing Then
Debug.Print h.SubAddress & " contains '" & b.Range.Text & "'"
End If
Next h
End Sub