FileSaveAs in a Macro Overwrites Existing Files Without Prompt

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

Additional query words: docerr doc err 2.0 word6 7.0 word95 word7 winword 6.0 winword2

Keywords : kbhelp
Version : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a
Platform : WINDOWS
Issue type :


Last Reviewed: September 29, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.