GetOpenFileName

  • Thread starter Thread starter Tomski
  • Start date Start date
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
 
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
 
Back
Top