Are there controls DriveListBox and FileListBox in VBA?

hi,experts,

Do any experts know if there are controls in VBA same as VB DriveListBox and FileListBox because I need to browse files in some directory within my VBA code (EXCEL macro)? Any suggestions for this?

thanks in advance,
pxiaoAsked:
Who is Participating?
 
Erick37Connect With a Mentor Commented:
You can use the SHBrowseForFolder API to display a system browse dialog box to select a file.  Sample VB code:

http://www.thescarms.com/vbasic/DirectoryBrowser.htm
0
 
VbmasterCommented:
The Dir statement is available in VBA. Look in your helpfile for more information about it, it can give you a list of all files/subdirectories in a directory.
0
 
Erick37Commented:
GetOpenFilename is way easier:

"Using GetOpenFilename to Get User Input"

http://www.microsoft.com/exceldev/tips/getopen.htm
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
pxiaoAuthor Commented:
Thanks for expert's help.

One more question:
as for the open file dialog, can I set a default driver and directory to look in?
0
 
Erick37Commented:
Which dialog box are you using?
0
 
pxiaoAuthor Commented:
I'm using GetOpenFilename to start a open-file dialog to load files.  But I need to point to a specified directory when starting the dialog.
But GetOpenFileName doesn't provide option to set directory for searching.

thanks,
0
All Courses

From novice to tech pro — start learning today.