The information in this article applies to:
SYMPTOMSIn Microsoft Excel, if you use the SaveAs method of the Workbook object to save a file, and you save the file with the same name and location as an existing file, you cannot determine whether the No or the Cancel button is chosen in the "Replace Existing" dialog box that appears when you save the file. CAUSEWhen you use the SaveAs method of the Workbook object to save a file, and the file already exists, both the No and the Cancel button in the "Replace Existing" dialog box cause the following error message to appear: Because of this behavior, you cannot trap this error, and you cannot determine in your macro whether the Cancel button was chosen, or the No button was chosen. WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspTo work around this behavior, you can use the Dir function to determine whether the file already exists, and then use the MsgBox function to trap the response to either replace the existing file, or not. The following macro is an example of this method.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. REFERENCESFor more information about the Dir function, click the Index tab in Microsoft Visual Basic Help, type the following text Dirand then double-click the selected text to go to the "Dir function" topic. For more information about the SaveAs method, click the Index tab in Microsoft Visual Basic Help, type the following text SaveAsand then double-click the selected text to go to the "SaveAs method" topic. "Microsoft Excel Visual Basic User's Reference" Chapter 9, "Handling Errors and Error Values" Additional query words: 5.00c 8.00 97
Keywords : kbprg kbdta KbVBA |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |