P
passion_to_be_free
I'm writing a subroutine that will go to a directory, open a csv file,
and parse the data line by line. The macro is set to continue this
process for all csv files in that specific directory.
All is going well, except on one of my csv files, the EOF registers as
true before it reaches the end of the file. I have hardcoded the path
to this specific file for testing purposes. Here is my code:
Sub CSV3()
Dim TextLine As String
Dim headings As Variant
Dim record As Variant
Dim counter
Dim fileNumber As Integer
templateDir = "" 'this does have a purpose...see SetDirectories3 Sub
SetDirectories3
csvFile = "Macintosh HD:Users:tlscprojectsesktop:CPAS Final
Reportsata Files:CPAS, F06, ELED 302, Sec 1, ElEd, Welling.csv"
Open csvFile For Input As #1 ' Open file.
Line Input #1, TextLine ' Read line into variable.
headings = Delim(TextLine)
errorLog = Date & vbCr & Time & vbCr & stName 'start the Error Log
Application.ScreenUpdating = False
MsgBox "loc: " & Loc(1)
MsgBox "length: " & LOF(1)
MsgBox EOF(1)
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
record = Delim(TextLine)
'these subroutines parse the data
newReporter headings, record
LogInformation (errorLog)
Documents(DocName).Close (wdSaveChanges)
Documents("Final Evaluation Creator2.doc").Activate
errorLog = ""
Loop
Close #1 ' Close file.
End Sub
Now, when I run the sub, I get these dialog windows:
loc: 45
length: 5639
True
If I am at location 45, and the document length is 5639, then why is
EOF evaluating as true? Anyone have any suggestions?
and parse the data line by line. The macro is set to continue this
process for all csv files in that specific directory.
All is going well, except on one of my csv files, the EOF registers as
true before it reaches the end of the file. I have hardcoded the path
to this specific file for testing purposes. Here is my code:
Sub CSV3()
Dim TextLine As String
Dim headings As Variant
Dim record As Variant
Dim counter
Dim fileNumber As Integer
templateDir = "" 'this does have a purpose...see SetDirectories3 Sub
SetDirectories3
csvFile = "Macintosh HD:Users:tlscprojectsesktop:CPAS Final
Reportsata Files:CPAS, F06, ELED 302, Sec 1, ElEd, Welling.csv"
Open csvFile For Input As #1 ' Open file.
Line Input #1, TextLine ' Read line into variable.
headings = Delim(TextLine)
errorLog = Date & vbCr & Time & vbCr & stName 'start the Error Log
Application.ScreenUpdating = False
MsgBox "loc: " & Loc(1)
MsgBox "length: " & LOF(1)
MsgBox EOF(1)
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
record = Delim(TextLine)
'these subroutines parse the data
newReporter headings, record
LogInformation (errorLog)
Documents(DocName).Close (wdSaveChanges)
Documents("Final Evaluation Creator2.doc").Activate
errorLog = ""
Loop
Close #1 ' Close file.
End Sub
Now, when I run the sub, I get these dialog windows:
loc: 45
length: 5639
True
If I am at location 45, and the document length is 5639, then why is
EOF evaluating as true? Anyone have any suggestions?