使用 VBA 关注超链接

Follow hyperlink using the VBA

如何在 Microsoft Word 2016 中跟踪超链接?

这在 Excel 中工作正常:

' Works in Excel
Sub FollowURL()
    ActiveCell.Hyperlinks(1).Follow
End Sub

但是,当我尝试将 ActiveCell 更改为 Selection(假设它是 Word 所必需的)时,它不起作用:

' Doesn't work in Word
Sub FollowURL()
    Selection.Hyperlinks(1).Follow
End Sub

怎么样:

' Note: Ensure the selection contains "http://..."
' for example: http://www.google.com

ActiveDocument.FollowHyperlink Selection.Text

注意:你检查你的防火墙让word使用这个功能作为@john c。 j.评论中提到。