LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default OpenText runtime error '1004'

I am trying to write a script to open and format a series of text files.

I have recorded a macro, then edited it to make it more generally useful.
The recorded macro looks like:

Workbooks.OpenText Filename:= _
"C:\Documents and Settings\CSMITH8\Desktop\Project
Simplify\WithHeaders\DETALL.TXT" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False _
, Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5,
1), Array(6, 5), _
Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1),
Array(12, 1), Array(13, 1 _
), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18,
1), Array(19, 1), Array _
(20, 1), Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1),
Array(25, 1), Array(26, 1), _
Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31,
1), Array(32, 1), Array( _
33, 1)), TrailingMinusNumbers:=True


The code I am trying to run is:

Workbooks.OpenText _
Filename:=strPCFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, _
Comma:=False, Space:=False, Other:=True, OtherChar:="|", _
FieldInfo:=strDetCols, _
TrailingMinusNumbers:=True

This code fails with "runtime error '1004' Method "OpenText of object
'Workbooks' failed."

I have checked the two variables (strDetCols and strPCFileName), and there
are two differences:

1) strPCFilename does not have double quotes at the beginning and end
2) strDetCols uses the excel constants instead of the numbers (ie. Array(02,
xlGeneralFormat) instead of Array(02, 1)).

I have tried changing the constants to numbers and re-running. I get the
same problem.

I have no idea how to get double quotes into the string, or if that is even
the problem.

Any help that can be given would be greatly appreciated.

Thank you.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime error 1004 Oldjay Excel Programming 5 June 1st 06 11:15 PM
Keep getting runtime error 1004 [email protected] Excel Programming 8 October 11th 05 02:02 AM
Runtime error 1004 Daniel Excel Programming 2 July 19th 05 04:37 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Runtime error 1004 with method OpenText - but only on one computer Kew[_2_] Excel Programming 0 August 30th 04 11:52 PM


All times are GMT +1. The time now is 11:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"