Consulting

Results 1 to 5 of 5

Thread: view hyperlink on a userform

  1. #1
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    5
    Location

    Question how to view hyperlink from worksheet to userform?

    Hi everyone!I am new with VBA, i have made a VB program in excel, a useform, 5 labels and a combobox. A user selects from the combobox and the informationof that particular selction appears on the labels. Now,the workbook source of my program has cells that has hyperlinks. The word can be viewed on the labels but it's not a hyperlink. I want that the hyperlink can be viewed on the userform's labels so that the user can click on it to access the linked file.Is it possible? Or there's an alternative way of achieving it with the same results?Thanks.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I think that you need to get the address or the subaddress properties of the hyperlink object. Without seeing your code, I would struggle to be more precise.

  3. #3
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Hi hamz, welcome to VBAX

    This is one way you could do it, just by using the click event of the Label object on your form. On the Initialize event (right before the form loads) I tooks cells from Sheet1 column A that only had hyperlinks and stored them into a 2-dimensional array (one slot for the cell text, and the other for the hyperlink address). Once you select an item from the combobox the label will show the text of the combobox. Once you select the label, the code will perform a search in the array for the text from the label. If there's a match, the code will use the ThisWorkbook.FollowHyperlink method to act as if you clicked a hyperlink. Please note that some users have experienced some kind of warning message when using the FollowHyperlink method, although I have not yet seen it.

    Take a look at the example, hope this helps




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  4. #4
    VBAX Newbie
    Joined
    Dec 2006
    Posts
    5
    Location

    view hyperlink on a userform

    Hi! thanks for your reply, below are the codes i use in viewing the cell content in sheet2 to a label. It can be view on the label but just a plain text, not ashyperlink format. [vba]Private Sub UserForm_Initialize()
    ComboBox1.RowSource = Sheet2.Range("E3", _
    Sheet2.Range("E65536").End(xlUp)).Address
    ComboBox1.ListIndex = 0
    ComboBox1.SetFocus
    End Sub

    Private Sub ComboBox1_Change()
    With Worksheets("Sheet2") Label1.Caption = .Range("D3").Offset(ComboBox1.ListIndex)
    Label2.Caption = .Range("G3").Offset(ComboBox1.ListIndex)
    Label3.Caption= .Range("C3").Offset(ComboBox1.ListIndex)
    Label4.Caption = .Range("F3").Offset(ComboBox1.ListIndex)
    End Sub[/vba]

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Moved to the Excel help forum and merged with duplicate post. hamz, you will find more help in this area for your question.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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