ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GetOpenFileName (https://www.excelbanter.com/excel-programming/341824-getopenfilename.html)

Tomski[_4_]

GetOpenFileName
 

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


--
Tomski
------------------------------------------------------------------------
Tomski's Profile: http://www.excelforum.com/member.php...o&userid=26824
View this thread: http://www.excelforum.com/showthread...hreadid=472937


Ron de Bruin

GetOpenFileName
 
Hi

See the second example on this page
http://www.rondebruin.nl/windowsxpzip.htm

You can use the code from that macro


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Tomski" 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


--
Tomski
------------------------------------------------------------------------
Tomski's Profile: http://www.excelforum.com/member.php...o&userid=26824
View this thread: http://www.excelforum.com/showthread...hreadid=472937




Jim Cone

GetOpenFileName
 
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"

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


Tomski[_5_]

GetOpenFileName
 

Nice one guys, thanks for that.



--
Tomsk
-----------------------------------------------------------------------
Tomski's Profile: http://www.excelforum.com/member.php...fo&userid=2682
View this thread: http://www.excelforum.com/showthread.php?threadid=47293



All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com