GetOpenFileName

T

Tomski

Hi,

Is there a way to select the folder path as opposed to the file path
using this method.

directory = Application.GetOpenFilename("Excel Files (*.xls), *.xls")

I want to use the save as window, similar to selecting the file path
with the above line. Things is I want the folder/directory path.

Any ideas would be greatly appreciated.

Cheers,

Tom
 
J

Jim Cone

Tom,
This gives you the folder for the file selected in GetOpenFileName...
'-------------------------------
Sub FolderFromFilePath()
Dim strLocation As Variant
Dim N As Long

strLocation = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If strLocation = False Then Exit Sub
For N = Len(strLocation) To 1 Step -1
If Mid$(strLocation, N, 1) = "\" Then Exit For
Next

strLocation = Left$(strLocation, N - 1)
MsgBox strLocation
End Sub
'-------------------------
Jim Cone
San Francisco, USA

"Tomski"
<[email protected]>
wrote in message

Hi,
Is there a way to select the folder path as opposed to the file path
using this method.
directory = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
I want to use the save as window, similar to selecting the file path
with the above line. Things is I want the folder/directory path.
Any ideas would be greatly appreciated.
Cheers,
Tom
 

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