Consulting

Results 1 to 7 of 7

Thread: Solved: Hyperlinking in buttons in UserForms

  1. #1

    Solved: Hyperlinking in buttons in UserForms

    Hi all

    probably a dumb one. ..how do I set a button in a userform to open a hyperlink (e.g a webpage?). And how do I set the size of the window that opens so that it isnt a full page?
    Sam

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Sam,
    Part 1
    [VBA]
    Private Sub CommandButton1_Click()
    ActiveWorkbook.FollowHyperlink "http://www.vbaexpress.com/forum/showthread.php?t=6168"
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    or better yet
    [vba]
    Private Sub CommandButton1_Click()
    ActiveWorkbook.FollowHyperlink _
    "http://www.vbaexpress.com/forum/showthread.php?t=6168"
    End Sub[/vba]

  4. #4
    Thanks Guys! I will mark it solved.

  5. #5
    Hi, sorry, not quite solved: I want the window that the hyperlink opens to be a certain size. The following method I have tried does not seem to work. Can anyone tell me why?

    [VBA]
    Private Sub PropertiesDefenceTaxonomyButton_Click()
    ActiveDocument.FollowHyperlink http://www.google.com
    With ActiveWindow
    Set .Height = 100
    .Width = 100
    End With
    End Sub
    [/VBA]

    Thank you, Sam

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I've "unsolved" this for the second part of your question.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Regular
    Joined
    Feb 2011
    Posts
    10
    Location
    Hi everyone,

    I want to do the same thing; just hyperlink from a button on a Word UserForm.

    I've added a simple button to the form and then added the code as mentioned earlier in this thread i.e.:

    [vba]Private Sub cmbHelpMe_Click()
    ActiveDocument.FollowHyperlink "the web address linked to"

    End Sub[/vba]

    But all I get when I click on the button is a long pause and then an error message as follows:

    Run-time error '4198'
    Command failed

    It does say "Word is preparing to load this document" at the bottom of the Word window (Status bar) during the pause. But that's it.

    I've searched and searched for an answer.

    Can anyone help?
    Thanks,
    John

Posting Permissions

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