Looking for code to browse Dir & Files

  • Thread starter Thread starter Neil Bhandar
  • Start date Start date
N

Neil Bhandar

Hello:

I have a form where the user enters the name of a dir and
file name. I wish to enhace my model by providing the user
the option to look up the dir and file name using a browse
button. Is there code out there that could reuse?

Your help is appreciated,
-Neil
 
Hi Neil,

Try this...
---------------------
Private Sub cmdBrowse_Click()
filename = Application.GetSaveAsFilename("", "Excel Files
(*.xls), *.xls")
Do While filename = ActiveWorkbook.FullName
MsgBox "You can not select " & ActiveWorkbook.FullName
& " as the new file name!", vbCritical, "File Name Error"
filename = Application.GetSaveAsFilename("", "Excel
Files (*.xls), *.xls")
Loop
If filename = False Then filename = ""
End Sub
 
to get the file=>Open dialog, you use

Application.GetOpenFileName()

see help for arguments.
 
Dan,

Thanks this is more on the lines of what I was looking
for... but in addition I need to be able to see the files
in the dir. not just directory names.

Is ther something out there that I could reuse?

Thanks,
-Neil
-----Original Message-----
Neil,

If you want to return a folder, check out these links

http://j-walk.com/ss/excel/tips/tip29.htm

http://www.bmsltd.co.uk/MVP/MVPPage.asp#JimRech
look for the BrowseForFolder

If you want an easy way to return the full path of a file use

MyFileName = Application.GetOpenFileName
Opens a "Open File" type dialog box...
check out the help for getopenfilename, there's a lot of
functionality that it would take to long to explain...

Dan E

"Neil Bhandar" <[email protected]>
wrote in message [email protected]...
 
Back
Top