FileSaveAs in a Macro Overwrites Existing Files Without Prompt

Last reviewed: July 30, 1997
Article ID: Q84697
The information in this article applies to:
  • Microsoft Word for Windows versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a

SYMPTOMS

In Microsoft Word for Windows, if you write a macro that uses the FileSaveAs macro command and gives the document the same name as an existing file, Word overwrites the existing file without warning.

CAUSE

There is a documentation error on page 208 of "Using WordBasic" by WexTech Systems and Microsoft. The same error appears in the Microsoft Word version 2.0 for Windows Help menu topic titled "FileSaveAs." The following statement is incorrect:

   If a file with the same name already exists, a message appears asking
   if you want to replace the existing file.

This error does not appear in Word version 6.0 Help menu topic titled, "FileSaveAs Statement."

WORKAROUND

The following message DOES appear if you run the FileSaveAs command by choosing Save As from the File menu and you type a filename that already exists:

   Do you want to replace the existing <filename>?

If you want this message to appear when you use the FileSaveAs command in a macro, your macro must call the Save As dialog box from the File menu, as shown in the following macro:

Sub MAIN
 Dim dlg As FileSaveAs
 GetCurValues dlg
 N = Dialog(dlg)
 If N = - 1 Then
  FileSaveAs dlg.Name
 End If
End Sub

Reference(s):

"Using WordBasic," by WexTech Systems and Microsoft, page 208

Kbcategory: kbusage kbmacro KBSubcategory: kbhelp


Additional query words: docerr doc err 2.0 2.0a word6 7.0 word95
word7 winword 2.0a-CD 2.0b 2.0c 6.0 winword2
Keywords : kbhelp
Version : 2.x 6.0 6.0a 6.0c 7.0 7.0a
Platform : WINDOWS


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: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.