Do this in the immediate window on a fresh book.
cells(3,1) = "A"
cells(3,2) = "B"
cells(4,2) = "C"
activesheet.saveas filename:="foo", fileformat:=xlText
As you see in foo.txt only rows 3 and 4 get saved.
How can I beat this? cells(1)="" is not sufficient to make the .saveas pick up the first two rows.
cells(1)=" " (a blank) does work, but that's disgusting. Any better ideas?
One more curiosity about xlText and xlCSV that seems related: an empty row in the "middle" of the data produces nothing but 0x0D, 0x0A. To see this add this
cells(6,1) = "D"
to the code above and do the .SaveAs. I kind of would have liked to see the next to last output row be
0x09, 0x0D, 0x0A
since the other rows with nonempty cells all have a tab. Even row 6 produces a tab at the end of the row.
The last point is easier to see with xlCSV. If any cells at all in a row are nonempty, N columns always produce N-1 commas. However no commas occur if the row has all empty cells. That might suck when parsing for commas in the .CSV; some rows would have commas, and some wouldn't. Is there any way around that behavior?
Bookmarks