Defaulting a folder for FileDialog in VBA
Add the folder path (including the trailing \
) to InitialFileName
. For example, to open the dialog in the user's home directory do:
f.InitialFileName = Environ("USERPROFILE") & "\"
If you forget the trailing \
,
then the dialog box will still open in the correct folder,
but the folder name will also appear as the default selected file name.
Then the dialog will be looking for a sub-folder with the same name, which usually doesn't exist.