Results 1 to 3 of 3

Transfering Userform textbox filepath to worksheet as a hyperlink.

Threaded View

  1. #1
    Registered User
    Join Date
    01-15-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    17

    Transfering Userform textbox filepath to worksheet as a hyperlink.

    Hello,

    I have a userform that populates an excel worksheet.

    The user fills in the userform, presses the "submit" button and it sends all the information to a spreadsheet.

    I have now added an option to reference appropriate files (pictures, documents etc.). On the same userform, the user can press a button which opens a file browser window. The user finds their file and presses "OK" and the file path is displayed in a text box that I've placed on the userform.

    When the "submit" button on the userform is pressed, the spreadsheet is populated including the file path bit.

    The above works well. In the database I can see the filepath as text but what I would like to do is have it as a hyperlink to the file itself.

    Therefore, rather than the userform populating the filepath as a piece of text, is it possible to populate it as a link to the document it's referring to?

    This is what I have done to get the filepath into the userform. The command button is called "Find_File" and the associated text box is called "File_Ref":

    Private Sub Find_File_Click()
         
        Dim Filename As Variant
        Filename = Application.GetOpenFilename("All Files (*.*),*.*")
            If Filename = False Then Exit Sub
            File_Ref.Value = Filename
    
    End Sub
    To send the userform information to a worksheet database I have used:


    Private Sub Submit_Click()
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Database")
    
    iRow = ws.Cells.Find(what:="*", SearchOrder:=xlRows, _
        SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
        
    ws.Cells(iRow, 2).Value = Me.Textbox1.Value
    ws.Cells(iRow, 3).Value = Me.Textbox2.Value
    ws.Cells(iRow, 4).Value = Me.File_Ref.Value
    
    End Sub

    Is there a way to get the last line like?:

    ws.Cells(iRow, 4).Value = Me.File_Ref.Hyperlink
    Last edited by SJJ; 02-29-2012 at 05:17 PM. Reason: Question solved

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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