GetOpenFilename and GetSaveAsFilename are useful dialogs to use within Excel VBA procedures when your procedure needs to know the filename of a file to open or save. I have encapsulated each into functions that add to their functionality, and make then simpler to use in my procedures.
Note that both GetXxxxFilename functions return file names. They do not open or save any files, merely provide a mechanism to ask the user for the names of the files that the calling procedure will process later.
The GetOpenFilename and GetSaveAsFilename functions as I use them are given by the following syntax; these arguments are optional, and I’ve left out optional arguments that I don’t use. I define a variant named vTemp to accept the return value of the function.
vTemp = Application.GetOpenFilename( _
FileFilter:=sFilter, Title:=sTitle, MultiSelect:=bMulti)
vTemp = Application.GetSaveAsFilename( _
FileFilter:=sFilter, InitialFileName:=sName, Title:=sTitle)