Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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]'?

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Keywords: KB818657, kbprb, kbnofix

↑ Back to the top

Article Info
Article ID : 818657
Revision : 6
Created on : 5/12/2007
Published on : 5/12/2007
Exists online : False
Views : 311