Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 29th, 2006, 11:12 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Import txt starting at a specific line

I am trying to select and copy text from a text file that I am opening in Notepad and paste the copied data into Excel. I have to open the txt file in Notepad b/c the file is too large to open in Excel. I need to copy all lines from 161,237 to EOF.

I am using this code to open the txt file:

Shell "Notepad.exe" & " " & "n:\myfiles\2006 Work\NEMS FY06\Fuel Cell Work\RDGENOUT.txt", _
vbNormalFocus

I can't figure out how to skip to line 161,237 in this file and select all lines to the EOF and copy these lines.


Reply With Quote
  #2 (permalink)  
Old March 29th, 2006, 11:24 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...

i dont follow you.. why are you opening the file in notepad and not just open in it vb??

HTH

Gonzalo
Reply With Quote
  #3 (permalink)  
Old March 29th, 2006, 11:36 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using VB in Excel to open the txt file in notepad using the code:

Shell "Notepad.exe" & " " & "n:\myfiles\2006 Work\NEMS FY06\Fuel Cell Work\RDGENOUT.txt", _
vbNormalFocus

I am unable to use VB code such as openText Filename b/c the txt file has more lines than Excel will handle.

Reply With Quote
  #4 (permalink)  
Old March 29th, 2006, 11:41 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

so, you are using VBA... can you just use the filesystemobject to open the file as a textstream?? that will do the things easy for you.. for that you will have to add a reference to microsoft scripting object..

HTH

Gonzalo
Reply With Quote
  #5 (permalink)  
Old March 29th, 2006, 11:46 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How would I then go to the necessary lines and select/copy them without select/copying the entire file?

Reply With Quote
  #6 (permalink)  
Old March 29th, 2006, 11:53 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well now you have to research a little.. the textstream object will open the file like a stream of chars. You can read lines in the file and then start copying when you reach the position you need...

i dont have an example here, but look in the msdn for it...

HTH

Gonzalo
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line printing to specific printers , trays sudarshan73 Reporting Services 0 January 23rd, 2007 03:51 PM
Import a fixed width txt file to access subhanak Access VBA 12 May 5th, 2006 05:35 AM
Import a Comma separated txt file to SQL table arielote C# 2 April 17th, 2006 01:08 AM
Reading line by line from a .txt file x_ray VB.NET 2002/2003 Basics 5 February 10th, 2006 01:55 PM
DTS - import txt , no order rows luma SQL Server DTS 2 July 14th, 2005 11:32 PM



All times are GMT -4. The time now is 05:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.