How to get the file path in a text box

Solved
r4944 Posted messages 136 Status Member -  
r4944 Posted messages 136 Status Member -
Bonjour,

I am looking for a function that can help me browse Word files through a browse button and display the path of the selected file in a textbox located right next to the browse button.

I have started with the code above, but it just opens the selected file, which is not really what I'm looking for.

Thank you


Dim vaFiles As Variant
Dim i As Long

vaFiles = Application.GetOpenFilename _
(FileFilter:="Word Files (*.docx),*.docx", _
Title:="Open File(s)", MultiSelect:=False)

If Not vaFiles = False Then

' Display the path in the textbox
TextBox1.Text = vaFiles
End If


Configuration: Windows 7 / Chrome 44.0.2403.130

1 answer

  1. Pllugy Posted messages 4 Status Member
     
    Hello,

    I believe I haven't fully understood, but I did this.

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Excel As New OpenFileDialog

    Excel.Filter = "Excel Files .xls|*.xls"

    If Excel.ShowDialog() = 1 Then

    TextBox1.Text = Excel.FileName

    Else

    End If
    End Sub

    End Class


    Aaron.
    0
    1. r4944 Posted messages 136 Status Member
       
      Hello,

      I tried it and I got a type mismatch error.
      0
      1. Pllugy Posted messages 4 Status Member > r4944 Posted messages 136 Status Member
         
        Hello,

        Where do you have an error?

        Aaron
        0
    2. r4944 Posted messages 136 Status Member
       
      Re,
       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
      0