Share via

Hyperlink using Command Button

Anonymous
2011-08-25T15:26:37+00:00

Hello,

I'm trying to use VBA to launch a hyperlink from a command button in Word.

I'm getting an Argument not Optional error on the (.Add).

Private Sub CommandButton1_Click()

    strURL = "http://www.google.com"

    ActiveDocument.Hyperlinks.Add Address:=strURL

End Sub

Can anyone help? Thanks

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-08-25T15:36:16+00:00

Try this instead:

Private Sub CommandButton1_Click()

    Dim strURL As String

    strURL = "http://www.google.com"

    ActiveDocument.FollowHyperlink Address:=strURL

End Sub

Was this answer helpful?

5 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2011-08-25T18:53:14+00:00

    Thanks!

    Was this answer helpful?

    0 comments No comments