Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL assigned to a button

Status
Not open for further replies.

christopher007

Instructor
Nov 14, 2003
29
GB
Would anyone be kind enough to let me know how I can assign a url to a button, or let me know the VBA code, so that when a user clicks on a button on a spreadsheet it opens a url in the default browser. Just like as if you insert a hyperlink in a cell with the insert hyperlink button.

Thanks in advance
Chris
 
Hi,

This is from the Office 2k help files and should point you in the right direction.

Code:
Private Sub Form_Load()
    Dim ctl As CommandButton
    Set ctl = Me!Command0
    With ctl
        .Visible = False
        .HyperlinkAddress = "[URL unfurl="true"]http://www.microsoft.com/"[/URL]
        .Hyperlink.Follow
    End With
End Sub

Hope this helps.


Leigh Moore
Solutions 4 MS Office Ltd
 
I cant make heads nor tails of this code were did you find it, i have tried looking in VBA help but only find about inserting hyperlinks in cells.

Any more help would be greatly recived.
 
Found the answer to my own question:-

Private Sub CommandButton1_Click()

ActiveWorkbook.FollowHyperlink Address:="URL GOES HERE", _
NewWindow:=True

End Sub

Cheers for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top