Follow hyperlink using the VBA

2019-08-20 02:57发布

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条回答
Anthone
2楼-- · 2019-08-20 03:33

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.

查看更多
登录 后发表回答