Follow hyperlink using the VBA

2019-08-20 02:34发布

问题:

How to follow hyperlinks in Microsoft Word 2016?

This works fine in Excel:

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

However, when I try to change ActiveCell to Selection (assuming it is necessary for Word), it doesn't work:

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

回答1:

What about:

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

ActiveDocument.FollowHyperlink Selection.Text

Note: That you check your firewall to let word use this function as @john c. j. mentioned in the comments.