+ Reply to Thread
Results 1 to 6 of 6

Activating hyperlink with a command button?

  1. #1
    Registered User
    Join Date
    02-17-2006
    Posts
    11

    Activating hyperlink with a command button?

    Can someone help with this query? I'm sure it's simple... but I just can't figure it.

    I have created a spreadsheet and added command buttons, which I intend to use to activate hyperlinks.

    I managed to add a hyperlink to the button in design view mode, which works fine when clicking the button.. but only in design mode! When you switch back to normal mode, clicking the button does nothing.. as there is no actual code behind it.
    Is there anyway someone could show me the code needed to active the hyperlink assigned to my command button?

    Thanks in advance

    Chris

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Chris,

    Hyperlinks can attached to Drawing and Auto Shapes, but not to Forms controls. Controls have to call an external hyperlink. This macro is for Forms Command Buttons. The Select Case statement allows you to expand the buttons that call hyperlinks. The macro assumes the buttons and hyperlinks are on the same page. They don't have to be, but the code would need to be modified to handle that condition. You only need to enter the Button's name and the cell address of the hyperlink in the code. You can then assign this routine to the Command Buttons in the macro's list. This example assumes the ActiveSheet has a Forms Command Button named "Button 1", and a hyperlink in cell "H2". The .Hyperlinks(1).Follow remains the same for each new Case statement you add.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    02-17-2006
    Posts
    11
    Many thanks for your comments.

    Works brilliantly!

    Regards

    Chris

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177
    Quote Originally Posted by Leith Ross
    Hello Chris,

    Hyperlinks can attached to Drawing and Auto Shapes, but not to Forms controls. Controls have to call an external hyperlink. This macro is for Forms Command Buttons. The Select Case statement allows you to expand the buttons that call hyperlinks. The macro assumes the buttons and hyperlinks are on the same page. They don't have to be, but the code would need to be modified to handle that condition. You only need to enter the Button's name and the cell address of the hyperlink in the code. You can then assign this routine to the Command Buttons in the macro's list. This example assumes the ActiveSheet has a Forms Command Button named "Button 1", and a hyperlink in cell "H2". The .Hyperlinks(1).Follow remains the same for each new Case statement you add.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Your code as is would not work for me, not sure why, but this snipet did (edited your code).
    Please Login or Register  to view this content.
    As long as the hyperlink is in cell A51 of the active sheet all is well.
    Regards

    Rick
    Win10, Office 365

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177
    Well...
    Because I started with a Hyperlink I instilled in myself I must continue with a hyperlink.
    That is not so. :lol:
    All I needed was the following for my commandbuttons:
    Please Login or Register  to view this content.


    Lesson learned!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Rick,

    I will answer your question, but please read the forum rules about posting. You should not add a new question on to an existing post. You should start a new thread. Here is a link to the forum rules http://www.excelforum.com/showthread.php?t=591596

    The code didn't work for you because your command button is from the Control Toolbox, and not the Forms toolbar.

    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1