Excel SaveAs Method Does Not Set Saved Property for .txt or .csv Files (818657)



The information in this article applies to:

  • Microsoft Office Excel 2003
  • Microsoft Excel 2002
  • Microsoft Excel 2000
  • Microsoft Excel 97 for Windows

SYMPTOMS

When you use the programmatic SaveAs method in Microsoft Excel to save a new workbook or an existing workbook as either a tab delimited (*.txt) or a comma delimited (*.csv) text file, Excel does not set the Saved property to True on a successful save. Therefore, when you close a workbook, you may be prompted to save changes. This problem occurs even though the data was saved as plain text. You are prompted with the following message:Do you want to save changes to '[bookname]'?

CAUSE

Excel workbooks contain a lot of data. The data includes styles, formats, formulas, cell spacing, and active selection. This data cannot be persisted in a plain text file. Only the native Excel formats (*.xls or *.xla) or HTML formats (*.htm or *.mht) can perform a full save on a workbook. If you save a new workbook or an existing workbook as a .txt or .csv text file, then changes remain that are associated to that workbook that cannot be saved with the SaveAs operation. Therefore, Excel does not change the Saved flag for the workbook, and you are prompted when you try to close the file.

STATUS

This behavior is by design. Excel always prompts you about unsaved changes to a file when you try to close the file. If you want to avoid this prompt, set the Saved property to True in your code.

Modification Type:MajorLast Reviewed:9/19/2003
Keywords:kbnofix kbprb KB818657 kbAudDeveloper