can a dialogue return a selected file path?

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
 
B

Bernie Deitrick

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top