Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi Jat,
Can you open the file manually in Excel? If not, what type of file extension does it have; is it .txt? If you cannot see the file extension then open Control Panel - Folder Options - View tab and uncheck 'Hide extensions for known file types'. If it is not .txt then copy the file to a new filename and then rename it to ..txt (Ignore the warnings about renaming) and try to open the new file with Excel again and if that works test the code again with the renamed file. If code is still not working, record a macro to open it and compare the recorded code with the code you posted. If you still can't sort it out then post the recorded code so that I (or someone else) can compare it. -- Regards, OssieMac |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Opening Excel, Book1 opens, remains open with other workbook open | Excel Discussion (Misc queries) | |||
how do i open a data workbook when i open a timesheet workbook | Excel Discussion (Misc queries) | |||
excel 2003 saved file will not open without a blank workbook open | Excel Discussion (Misc queries) | |||
Search open sheets in workbook and insert into open sheet | Excel Discussion (Misc queries) | |||
Excel workbook does not open in open window on desktop | Excel Discussion (Misc queries) |