WD: Macro to Change Default FileSaveAs Directory

Last reviewed: November 26, 1997
Article ID: Q110629
The information in this article applies to:
  • Microsoft Word for Windows, version 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, versions 7.0, 7.0a

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 : kbmacroexample winword winword2 word6 word7 word95 wordnt kbmacro kbusage
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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 26, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.