Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default import text w/macro

I've tried recording a macro that will open a text file into Excel 2003. The
text file has over 256 columns, so while recording the macro i set some
columns to be "skipped" (not imported). When i clicked "finish", i got an
error message about "Too many line continuations".

The text file did open fine, but when i looked at the recorded macro in VBA,
the code was in red and was clearly cut off after a certain point.

Is there a way i can write code/record a macro to open this text file
(again, i just want to import some of the 256+ columns) that won't run into
the "Too many line continuations" problem?

Thanks
rachael
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default import text w/macro

Maybe import it line by line, cut the information you need, and paste
it. Here's an example:

strSourceFile = "C:\Sample.txt"
lngInputFile = FreeFile
Open strSourceFile For Input As lngInputFile
iRowCount = 1
While Not EOF(lngInputFile)
Line Input #lngInputFile, strInText
strOutText = Left(strInText, 40) & Mid(strInText,100,40) &
Right(strInText,50)
Cells(iRowCount,"A")=strOutText
iRowCount = iRowCount + 1
Wend
Close lngInputFile

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default import text w/macro

I believe the limit on continuation characters is 9. Take the code and
manually remove some of the line continuations so the individual "pieces" are
longer. They'll probably run off the screen to the right, so it will be harder
to read.

You say the line has been truncated, so you'll have to figure out what has
been lost and add those fields manually. Maybe you can determine that by
looking at the properties for the fields that have been included in the code.

If that fails, you'll have to read the file line by line, splitting it with
the Split command (let's hope it's a TAB rather than a comma). You'll have to
remove any quote characters too.

If the delimiter is a comma and you have quoted text with embedded commas,
this won't work.

On Thu, 4 Nov 2004 15:06:02 -0800, rachel
wrote:

I've tried recording a macro that will open a text file into Excel 2003. The
text file has over 256 columns, so while recording the macro i set some
columns to be "skipped" (not imported). When i clicked "finish", i got an
error message about "Too many line continuations".

The text file did open fine, but when i looked at the recorded macro in VBA,
the code was in red and was clearly cut off after a certain point.

Is there a way i can write code/record a macro to open this text file
(again, i just want to import some of the 256+ columns) that won't run into
the "Too many line continuations" problem?

Thanks
rachael


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default import text w/macro

Of course! I actually thought of that last night as i was falling asleep (why
didn't i think of it before??).

I think removing the line continuations will be easier than importing line
by line.

Thanks!
rachael

"Myrna Larson" wrote:

I believe the limit on continuation characters is 9. Take the code and
manually remove some of the line continuations so the individual "pieces" are
longer. They'll probably run off the screen to the right, so it will be harder
to read.

You say the line has been truncated, so you'll have to figure out what has
been lost and add those fields manually. Maybe you can determine that by
looking at the properties for the fields that have been included in the code.

If that fails, you'll have to read the file line by line, splitting it with
the Split command (let's hope it's a TAB rather than a comma). You'll have to
remove any quote characters too.

If the delimiter is a comma and you have quoted text with embedded commas,
this won't work.

On Thu, 4 Nov 2004 15:06:02 -0800, rachel
wrote:

I've tried recording a macro that will open a text file into Excel 2003. The
text file has over 256 columns, so while recording the macro i set some
columns to be "skipped" (not imported). When i clicked "finish", i got an
error message about "Too many line continuations".

The text file did open fine, but when i looked at the recorded macro in VBA,
the code was in red and was clearly cut off after a certain point.

Is there a way i can write code/record a macro to open this text file
(again, i just want to import some of the 256+ columns) that won't run into
the "Too many line continuations" problem?

Thanks
rachael



Reply
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
How do I call up the Text Import Wizard via a macro. Computer, call me if you have a problem Excel Worksheet Functions 4 October 11th 07 10:06 PM
Macro to Import Text Miasha Excel Discussion (Misc queries) 8 August 18th 06 04:30 PM
Text Import Macro Help Obbly Excel Programming 1 October 12th 04 09:16 PM
Import text wizard in a macro Dennis Vlasich Excel Programming 3 June 21st 04 11:24 PM
Creating a macro to use the text import wizard abxy[_2_] Excel Programming 3 January 11th 04 12:43 AM


All times are GMT +1. The time now is 07:31 PM.

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

About Us

"It's about Microsoft Excel"