View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
jat jat is offline
external usenet poster
 
Posts: 33
Default Cannot open text workbook

i am using the following code to open two txt files that open fine in notepad:

Workbooks.OpenText "C:\Orders\" & Range("B2"), Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
1), Array(10, 1), Array(40, 1), Array(58, 1), Array(68, 1)),
TrailingMinusNumbers:=True

this first code works fine to open the file and edit the document in excel
2007.

the following code in a second macro gives an error message:
"This file is not in a recognizable format...., if you know the file is from
another program which is incompatible...., if you suspect the file is
damaged,......, if you still want to see what text is contained .....

the code to open the second file is:
Workbooks.OpenText Filename:="C:\Orders\" & Range("B4"), Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
1), Array(10, 1), Array(18, 1), Array(30, 1), Array(60, 1),
Array(66, 1)), TrailingMinusNumbers:=True

what's wrong with the second code?

jat