ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding a Workbook's Location (https://www.excelbanter.com/excel-programming/352461-finding-workbooks-location.html)

Bill[_30_]

Finding a Workbook's Location
 
Hello,
I would like to find a workbooks on the C directory, but searching all files
takes too long. Is there a quicker way? Is there a way to ask the user to
enter the folder where the file is located (like the browse dialog box)?

Thanks.

Bill



Dave Peterson

Finding a Workbook's Location
 
You could use a macro that opens the File|Open dialog to get the name of an
existing file.

Dim myFileName as Variant
myfilename=application.getopenfilename("excel files, *.xls")
if myfilename=false then
'user hit cancel
'do something
else
msgbox myfilename 'do whatever you need with that variable
end if

===

If you're really just looking for a folder name from the user...

Jim Rech has a BrowseForFolder routine at:
http://www.oaltd.co.uk/MVP/Default.htm
(look for BrowseForFolder)

John Walkenbach has one at:
http://j-walk.com/ss/excel/tips/tip29.htm

If you and all your users are running xl2002+, take a look at VBA's help for:
application.filedialog(msoFileDialogFolderPicker)



Bill wrote:

Hello,
I would like to find a workbooks on the C directory, but searching all files
takes too long. Is there a quicker way? Is there a way to ask the user to
enter the folder where the file is located (like the browse dialog box)?

Thanks.

Bill


--

Dave Peterson


All times are GMT +1. The time now is 05:19 AM.

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