Hi folks,
My first post here. Here is my problem. I am using Excel VB to open a text file and extract information from it. Here is my code.
Private Sub Parse_EventLogs(EventLogDir As String)
Dim File As String ' File handle for the eventlog file
Dim FCount As Long ' Total number of eventlog files processed
Dim Processedcount As Long ' Total number of eventlog files processed
Dim fn As Integer ' File number
Dim thisline As String
FCount = 0
File = Dir(EventLogDir)
'find out total numberof eventlogs in the directory
Do While Len(File) > 0
FCount = FCount + 1
File = Dir
Loop
File = Dir(EventLogDir)
Processedcount = 0
Do While Len(File) > 0
Processedcount = Processedcount + 1
LogInfo " Processing file " & Processedcount & " of " & FCount
fn = FreeFile()
Open File For Input As #fn
Do While Not EOF(fn)
Line Input #fn, thisline
'Extract Data
Loop
File = Dir
Loop
End Sub
The code goes to the directory and gives an a correct count of how mnay files are in the directory. The variable 'File' has a valid filename all the way through. But when it goes to execute the 'Open' statement, it says runtime error 53 File not found. I don't understand. The file exists, the file name is valid but it cannot open it. I changed the attribute on the entire folder and still the same error. I have another function writing a log file and that seems to open the file no problem.
Please help. Thanks.
My first post here. Here is my problem. I am using Excel VB to open a text file and extract information from it. Here is my code.
Private Sub Parse_EventLogs(EventLogDir As String)
Dim File As String ' File handle for the eventlog file
Dim FCount As Long ' Total number of eventlog files processed
Dim Processedcount As Long ' Total number of eventlog files processed
Dim fn As Integer ' File number
Dim thisline As String
FCount = 0
File = Dir(EventLogDir)
'find out total numberof eventlogs in the directory
Do While Len(File) > 0
FCount = FCount + 1
File = Dir
Loop
File = Dir(EventLogDir)
Processedcount = 0
Do While Len(File) > 0
Processedcount = Processedcount + 1
LogInfo " Processing file " & Processedcount & " of " & FCount
fn = FreeFile()
Open File For Input As #fn
Do While Not EOF(fn)
Line Input #fn, thisline
'Extract Data
Loop
File = Dir
Loop
End Sub
The code goes to the directory and gives an a correct count of how mnay files are in the directory. The variable 'File' has a valid filename all the way through. But when it goes to execute the 'Open' statement, it says runtime error 53 File not found. I don't understand. The file exists, the file name is valid but it cannot open it. I changed the attribute on the entire folder and still the same error. I have another function writing a log file and that seems to open the file no problem.
Please help. Thanks.