How To Offset a specific Number of Rows in a Text File

  • Thread starter Thread starter R Tanner
  • Start date Start date
R

R Tanner

Hi,

I have a macro that is going through and evaluating each line of a
text file and importing it if it meets specific criteria. I need to
skip a certain number of rows if a certain criteria is met. What
syntax would I use to skip down a certain number of lines? This is
how I have been opening the file thus far.

FileNum=FreeFile

FileName = "Q:\Operations\Feedback Scores.LOG"

Open FileName For Input Lock Write as FileNum
 
I wouldn't use the "Open File For" method.

If you add a reference to Microsoft Scripting Runtime (Tools, References)
you get access to the TextStream object. You can use it like this:

Dim myFileSytem as Scripting.FileSystemObject
Dim myStream as TextStream
Dim myLine as String
Set myFileSytem = CreateObject("Scripting.FileSystemObject")
Set myStream = myFileSytem.OpenTextFile("C:\text.ini") 'or whatever path
While myStream.AtEndOfStream = False
myLine = myStream.ReadLine
'code here
Wend
myStream.Close

This reads through the text file line by line. To ignore soem lines you just
put code in the While...Wend loop that reads those lines but takes no action..
 
Back
Top