WD: Macro to Change Default FileSaveAs Directory

ID: Q110629

The information in this article applies to:

SUMMARY

In Word for Windows, the Save As command on the File menu always uses the current directory by default. Since the current directory can change, (for example when you insert a picture from a ClipArt directory), the default directory may not be consistent.

To configure Word to default to a specific directory when saving files, modify the FileSaveAs macro.

MORE INFORMATION

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

To modify the FileSaveAs macro to default to a specific directory when Word performs a Save As:

1. From the Tools menu, choose Macro.

2. In the Macro Name box, type "FileSaveAs" (without the quotation marks).

3. Click the Create button.

   The macro should appear as follows:

      Sub MAIN
      Dim dlg As FileSaveAs
      GetCurValues dlg
      Dialog dlg
      Super FileSaveAs dlg
      End Sub

4. Change the macro to the following (in this example, the default
   directory is being changed to "C:\WINWORD"):

   Word for Windows 2.0
   --------------------

      Sub MAIN
         Dim dlg As FileSaveAs
         GetCurValues dlg
         ChDir "C:\WINWORD"                     ' this line is new
         n = Dialog dlg                         ' this line is modified
         If n = - 1 Then Super FileSaveAs dlg   ' this line is modified
      End Sub

   Word for Windows NT, Word for Windows 6.0, Word for Windows 95
   --------------------------------------------------------------

      Sub MAIN
         Dim dlg As FileSaveAs
         GetCurValues dlg
         ChDir "f:\winword"      'use any existing directory here
         dlg.AddToMru = 1
         If Dialog(dlg) Then FileSaveAs dlg
      End Sub

   NOTE: You can specify any valid path you want on the ChDir line.

5. From the File menu, choose Close. When you are prompted to keep the
   changes to Global:FileSaveAs, choose Yes.

6. From the File menu, choose Exit. When you are prompted to save global
   glossary and command changes, choose Yes.

Word will now always default to the directory specified in the FileSaveAs macro when saving a file.

For more information about changing the default directory, query on the following words in the Microsoft Knowledge Base:

   default and change and working and directory and icon

Additional query words:
Keywords          : kbmacro kbusage wordnt kbmacroexample winword word6 winword2 word7 word95 
Version           : 2.0 2.0a 2.0a-CD 2.0b 2.0c 6.0 6.0a 6.0c 7.0 7.0a
Issue type        : kbhowto

Last Reviewed: November 28, 1997