Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open File in a User Form (Excel 2002)

    Hi,

    Is it pssible to define field in a Userform and when you click in that field is will call the Application.GetOpenFilename function. I am trying to open a file and get the file path and name into a field in a form.

    Many thanks.

    Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open File in a User Form (Excel 2002)

    That is possible, but I wouldn't use the On Click event of a text box - that is counterintuitive, for the user won't be able to select or edit text in the text box. Instead, I would use the On Click event of a command button, or if you prefer to use an event of the text box itself, take the On DblClick event.

    Example, assuming a text box txtFilename and a command button cmdGetFilename:

    Private Sub cmdGetFilename_Click()
    Dim varFile As Variant
    varFile = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
    If Not (varFile = False) Then
    Me.txtFilename = varFile
    End If
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open File in a User Form (Excel 2002)

    Thanks Hans,

    I will try that now.

    Regards

    Mike

Posting Permissions

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