MrExcel Publishing
Your One Stop for Excel Tips & Solutions

How to let user select directory, but macro assign file name on a saveas


Posted by Tom on January 25, 2002 9:58 AM

The situation:

A file with blanks is opened. The user fills in the blanks. Now the user is to save it in a new directory, but the macro is to assign the file name. How? My concern with using the xldialogSaveas is that the user could assign a different name. And I have tried the Application.GetSaveAsFilename, but when I try saving, the file still reverts back to the original name (maybe I'm using it incorrectly?)


Posted by John on January 25, 2002 1:42 PM

You can use and API call to open a dialog box that allows your user to choose a directory. That directory path is then returned to you to use in saving the file. This site will give you the code for the directory dialog:

http://www.vbapi.com/ref/s/shbrowseforfolder.html