Importing Text files w/o losing special characters
put your string in cell A1. Then in B1 or another cell in the first row put
in this formula
=CODE(MID($A$1,ROW(),1))
Assume the above formula is in B1
in C1:
=CHAR(B1)
now select B1:C1 and drag fill down until the formula starts returning
#Value errors.
The only thing between the characters in your post are ascii code 32 which
is a space.
Possibly they didn't get carried forward in the email.
--
Regards,
Tom Ogilvy
"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
|