View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default Stop Excel from stripping out leading zeros when saving as CSV

It's not the saving, it's the re-opening. After you save the file as .csv,
open the csv with notepad, the leading zero will be there.

If you rename the file to .txt and then open it with Excel, Excel will bring
up the Import Wizard and allow you to specify text.
--
Gary's Student


"MattM" wrote:

Hi, I am getting strange behaviour from Excel when working with CSV files.

It's quite easy to reproduce the problem:
1) In a text editor, such as Notepad, create the file "test.csv", containing
this data:
001,hello
2) Close the file
3) Open the same file up in Excel and change the value in B1 to "goodbye"
4) Save, clicking "Yes" when Excel asks if I want to keep CSV format, and
close Excel
6) Open the file in the text editor. It now contains:
1,goodbye

In other words, Excel has decided that "001" should be saved as "1". Is
there any way to stop this?
Regards
Matthew