Excel cutting out down over 1024 characters

3

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?

Zeno

Posted 2012-09-12T00:26:42.067

Reputation: 241

See this post from earlier today: http://superuser.com/a/472933/76571

– Excellll – 2012-09-12T01:14:17.673

Answers

5

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 & """";

Brian

Posted 2012-09-12T00:26:42.067

Reputation: 8 439

3

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

John

Posted 2012-09-12T00:26:42.067

Reputation: 1 869

It's definitely lost in the CSV. The cell in Excel which had 2000+ characters now contains 1023 characters in the CSV. – Zeno – 2012-09-12T00:38:45.410

1Hm. 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 – 2012-09-12T01:09:16.227

Oops sorry, I'm using an official Microsoft macro to save the file. See my edited question. – Zeno – 2012-09-12T02:25:19.577