Hello,
I'm using a simple VBA macro to save a block of cell's values to a file. This works well if there's one value per cell. But a couple cells have wrapped text that I want also printed exactly as seen in the cell. It uses Alt+Enter to wrap. I guess that doesn't translate into DOS text editors, since Wordpad shows long lines, and the program reading the block is crashing. Not sure how to attach a sample file, so I'll paste best i can here.
Here's the code:
Sub SaveDEL()
' shift+ctrl+s
' select the cell with the range limits and file path/name, and then run this.
Dim myFile As String, rng As Range, cellValue As Variant, i As Integer, j As Integer, WrdArray() As String, UpperLeft() As String, LowerRight() As String, UpperLeftRow As Integer, UpperLeftColumn As Integer, LowerRightRow As Integer, LowerRightColumn As Integer
WrdArray() = Split(ActiveCell.Value)
myFile = WrdArray(2)
UpperLeft() = Split(WrdArray(0), ",")
UpperLeftRow = UpperLeft(0)
UpperLeftColumn = UpperLeft(1)
LowerRight() = Split(WrdArray(1), ",")
LowerRightRow = LowerRight(0)
LowerRightColumn = LowerRight(1)
ActiveSheet.Range(Cells(UpperLeftRow, UpperLeftColumn), Cells(LowerRightRow, LowerRightColumn)).Select
Set rng = Selection
Open myFile For Output As #1
For i = 1 To rng.Rows.Count
For j = 1 To rng.Columns.Count
cellValue = rng.Cells(i, j).Value
If j = rng.Columns.Count Then
Print #1, Spc(1); cellValue
Else
Print #1, Spc(1); cellValue,
End If
Next j
Next i
Close #1
End Sub
When the print statement comes upon a cell with wrapped text, it prints all as one line. Even if I separate lines with CHAR(10), like:
="END" & CHAR(10) &
"ReallyEnd"
Hope there's a solution to this. Thanks for any help you can offer
Dave
I'm using a simple VBA macro to save a block of cell's values to a file. This works well if there's one value per cell. But a couple cells have wrapped text that I want also printed exactly as seen in the cell. It uses Alt+Enter to wrap. I guess that doesn't translate into DOS text editors, since Wordpad shows long lines, and the program reading the block is crashing. Not sure how to attach a sample file, so I'll paste best i can here.
Here's the code:
Sub SaveDEL()
' shift+ctrl+s
' select the cell with the range limits and file path/name, and then run this.
Dim myFile As String, rng As Range, cellValue As Variant, i As Integer, j As Integer, WrdArray() As String, UpperLeft() As String, LowerRight() As String, UpperLeftRow As Integer, UpperLeftColumn As Integer, LowerRightRow As Integer, LowerRightColumn As Integer
WrdArray() = Split(ActiveCell.Value)
myFile = WrdArray(2)
UpperLeft() = Split(WrdArray(0), ",")
UpperLeftRow = UpperLeft(0)
UpperLeftColumn = UpperLeft(1)
LowerRight() = Split(WrdArray(1), ",")
LowerRightRow = LowerRight(0)
LowerRightColumn = LowerRight(1)
ActiveSheet.Range(Cells(UpperLeftRow, UpperLeftColumn), Cells(LowerRightRow, LowerRightColumn)).Select
Set rng = Selection
Open myFile For Output As #1
For i = 1 To rng.Rows.Count
For j = 1 To rng.Columns.Count
cellValue = rng.Cells(i, j).Value
If j = rng.Columns.Count Then
Print #1, Spc(1); cellValue
Else
Print #1, Spc(1); cellValue,
End If
Next j
Next i
Close #1
End Sub
When the print statement comes upon a cell with wrapped text, it prints all as one line. Even if I separate lines with CHAR(10), like:
="END" & CHAR(10) &
"ReallyEnd"
Hope there's a solution to this. Thanks for any help you can offer

Dave