Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Excel 2003 to save a large file as a CSV.

But when saving cells that contain over 1024 characters, it cuts out the characters beyond 1024.

Per a previous question, I am using this official macro to save: http://support.microsoft.com/default.aspx?scid=kb;en-us;291296&Product=xlw

This macro in question is probably causing it, since I'm not using the normal Save As (in order to put quotes around every field).

It may not be 1024 characters, but long cells are getting cut off. What in this macro is causing that?

share|improve this question
    
See this post from earlier today: superuser.com/a/472933/76571 –  Excellll Sep 12 '12 at 1:14

2 Answers 2

up vote 5 down vote accepted

The code is too clever for it's own good. It uses the Text property, which is what is displayed in a cell, to get a text representation of a cells value. The problem as mentioned in another answer is this is limited to 1024 characters. You can change the code to use the Value property but this might not work on all cell value types.

Change this line:

Print #FileNum, """" & Selection.Cells(RowCount, ColumnCount).Text & """";

To:

Print #FileNum, """" & Selection.Cells(RowCount, ColumnCount).Value & """";
share|improve this answer

Actually, the data entered in the spreadsheet is still present in the cell. You can verify this by selecting the cell and looking at the formula bar.

However, Excel only displays up to 1024 characters.

When you save your spreadsheet as a CSV file, the physical data should be exported as you expect because it was never really lost. Here is Microsoft's guidance on this:

http://support.microsoft.com/default.aspx?scid=kb;en-us;211580

share|improve this answer
    
It's definitely lost in the CSV. The cell in Excel which had 2000+ characters now contains 1023 characters in the CSV. –  Zeno Sep 12 '12 at 0:38
1  
Hm. I'm not able to reproduce that problem. I created a spreadsheet in Office Standard 2003 and placed over 2500 characters into multiple cells. When I saved the spreadsheet to CSV, I still have the entire data set. –  John Sep 12 '12 at 1:09
    
Oops sorry, I'm using an official Microsoft macro to save the file. See my edited question. –  Zeno Sep 12 '12 at 2:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.