VBA - Windows API Open File Dialog
Uses the API to get a filename from the user. This differs from the built in GetOpenFilePath as it enables us to define a default directory without having to modify the user's Excel settings.
Some examples of the syntax for the
strFileFilter are listed below. The first part (before
& chr(0) is a description of the file type and anything can be given.
- CSV Files
- Text Files
- Excel Files
"CSV Files (.csv)" & chr(0) & "*.csv" & chr(0)
"Text Files (.txt)" & chr(0) & "*.txt" & chr(0)
"Excel Files (*.xls, *.xlsx, *.xlsm)" & chr(0) & "*.xls; *.xlsx; *.xlsm" & chr(0)