Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2006, 11:12 AM
Registered User
 
Join Date: Mar 2006
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.


 
Old March 29th, 2006, 11:24 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old March 29th, 2006, 11:36 AM
Registered User
 
Join Date: Mar 2006
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.

 
Old March 29th, 2006, 11:41 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old March 29th, 2006, 11:46 AM
Registered User
 
Join Date: Mar 2006
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?

 
Old March 29th, 2006, 11:53 AM
Friend of Wrox
 
Join Date: Jun 2003
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





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





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