Posted to microsoft.public.excel.programming
|
|
Importing Text files w/o losing special characters
Thank you, Nick, for showing me how to upload the file. Here is the link for
the file:
http://www.savefile.com/files/150039
To answer your question, the text file data is not fixed with but I've tried
fixed width as well as delimited...nothing works for me...the characters are
always stripped away.
"NickHK" wrote:
Tony,
Are the columns fixed width, as the parameter dataType:=xlFixedWidth
suggests ?
Are these special characters, ASCII value 255 ?
As for uploading a samle of the data,
http://savefile.com/
NickHK
"T_o_n_y" wrote in message
...
I need to import text files into Excel without losing special characters.
I've tried several methods, but each time Excel imports in the file,
ignoring
those characters. The following is an example line, but what you can't
see
are the 6 special characters which appear between the $$158 and the 1 8!
$$158 1 8 4.50 1.0000 0.8000 3.0010 1.5740
I know they are there, however since I opened the document using Word,
which displays them as a y with 2 dots above them.
My Excel VBA code needs to import these characters so that it doesn't get
lost when extracting the data using MID(,,,) function. The text file were
generated using old FORTRAN programs, and there are thousands of them...my
VBA routines need to access these files in order to modernize our system.
Examples of what I've tried (all of these ignore the y characters)
Workbooks.OpenText Filename:=fname, Origin:=437, _
StartRow:=1, dataType:=xlFixedWidth, FieldInfo:=Array(0, 2)
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & fname,
Destination:=Cells(2, Col))
Open FName For Input Access Read As #1
While Not EOF(1)
Line Input #1, WholeLine
Cells(RowNdx, ColNdx).Value = WholeLine
RowNdx = RowNdx + 1
Wend
Close #1
I would upload an example file showing the characters if someone tells me
how. I would also tell you what the characters are, again, if someone
tells
me how.
Thanks,
Tony
|