can a dialogue return a selected file path?

  • Thread starter Thread starter edward
  • Start date Start date
E

edward

Hello,

I am using an Excel dialogue to open up the windows file
menu in hopes of getting the file path for 2 files in
excel.
The code works ok


Public Sub GetUserFileName()

Dim UF As Variant

Dim UF1 As Variant


UF = Application.GetOpenFilename(Title:="Excel Files")

On Error Resume Next

Workbooks.OpenText Filename:=UF

End Sub

But I need to get the file path into a text box, that way
I can pass it into a function. If not is there another way
to open a file dialogue and get the file path?

Thanks
ed
 
Edward,

Application.GetOpenFilename

will return a string that includes the file path. For example:

Dim myFile As String
myFile = Application.GetOpenFilename
msgbox myFile

To actually open it, you would use

Workbooks.Open myFile
 
Back
Top