View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default 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