Too many line continuations

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,066
I am trying to record a macro to open a text file in excel however I keep getting the message too many line continuations.

My file that I am trying to open is 45000 rows but the problem is that it is 164 columns.

I have run a smaller file that only has 4 rows but still the 164 columns (as I can't change that) but I still get the message.

Can anyone help with a script to open it, I can't record a script at all therefore I have nothing to start with.

The first column needs to be as text.
 
Norie, code is

Code:
Sub test()
Dim I As Long
Dim arr1
ReDim Preserve arr1(I)
 
For I = 0 To 163
 
ReDim Preserve arr1(I)
 
arr1(I) = Array(I + 1, xlColumnDataType.xlGeneralFormat)
 
Next I
 
Workbooks.OpenText Filename:="C:\JInventTestCRC.asc", Origin:=xlMSDOS, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=True, FieldInfo:=arr1
end sub
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I don't see the problem either but I don't believe you need all those anyway. Try this and see if it works (the first column will be opened to text and the rest default to general format):

Code:
Workbooks.OpenText filename:="P:\JInventTestCRC.asc", Origin:=xlMSDOS, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=True, _
Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2)), TrailingMinusNumbers:=True
 
Upvote 0
Xenou,

You came through again, your code works great and is much easier to adapt than the one I was using.

Thanks heaps.:LOL::LOL::LOL:
 
Upvote 0
Eh, didn't I post something that looked like that code?:)

Only thing missing was the part to import column 1 as text, which I don't actually think would make much difference.

That is unless that column was some sort of number that you want to treat as text, eg an ID number.
 
Upvote 0
@Norie, yes, I see your post now ... I've been reading posts too quickly lately. :( I was thinking the same thing about the first column too. Glad we worked it out - I'm still not sure why the array of arrays failed but we can save that for another day :)
 
Upvote 0
xenou

The array of arrays does work - I tested it with various scenarios

eg skipping columns, randomly setting the data type for the columns etc

The code I posted where the array was created didn't have any declarations, and the OP seemed to be saying that was the problem.

Who knows, it's working anyway.:)
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top