FileFormat:=xlTextPrinter saves only 240 characters of cell

S

srinivasug

Hi,

I am using the following code i.e ConvertPC_8ToANSI() to open a DOS
based text file and then save it to WINDOWS ANSI text file. My text
file contains long records of more than 300 characters, following
procedure loads the entire record into one cell and while saving it, it
saves only 240 characters and truncates the remaining characters of the
cell (record). Any body knows how to come out of this max. character
limitation.

Thanks in advance!

----------------------------------
Sub ConvertPC_8ToANSI()

Dim sFil As String
Dim tmpWorkBook As Workbook

sFil = "Z:\SOS-DB Pre Migration\PC_8_TO_ANSI\tsf\sample.tsf"

Workbooks.OpenText Filename:=sFil, DataType:=xlDelimited,
textqualifier:=xlTextQualifierNone, Origin:=xlMSDOS
Set tmpWorkBook = ActiveWorkbook
tmpWorkBook.SaveAs Filename:=Left(sFil, Len(sFil) - 4) & "_3.tsf",
FileFormat:=xlTextPrinter
tmpWorkBook.Close

End Sub
 
W

windsurferLA

I'm no expert, but here is guess at possible solution inasmuch as no one
else has responded to your inquiry. Can you structure the data retrival
using the Right( ) and Left( ) to first retrieve the first 60
characters and then the remaining characters, if there are more than 60?
Place the text in adjoining cells and in necessary, use "&" to
join at a later point? I would think that you have tried it already in
that obviously you are aware of the Right() function.
 
A

Andrew B

Hi

Excel can only parse 255 characters at a time so if there are more than
that then you need to run a routine to parse them all. This could be the
problem.

For example, something like this is needed.

Sp.Shapes("ReturnSlip").Select
With Selection
.Text = ""
For i = 0 To Int(Len(RH) / 255)
.Characters(.Characters.Count + 1).Text = Mid(RH, (i * 255) +
1, 255)
Next
End With

I think Chip Pearson explains what to on his help pages.

Hope this helps a little.

Andrew B
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top