Hi
Something that wasn't obvious from the log file on the post (before attachment) was that there were multiple items to process in the same file. See how this goes.
Dim infilename As String 'name of the .txt file in the log
Dim filestring As String
Dim TextLine As String ' line of text
Dim filetoopen
Sub auto_open2()
'If IsEmpty(ActiveSheet.Range("a1").Value) = True Then
MsgBox ("Please select a Gateway log file")
' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
' ChDir should point to the location of your log files path located in quotation marks
'ChDir "\\Nycs00057034\SQMPLUS\data\logs\"
' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
filetoopen = Application.GetOpenFilename("Text Files (*.*), *.*")
If filetoopen = False Then
Exit Sub
End If
filestring = filetoopen
filestring = leftspace(filestring)
If MsgBox("Are you sure you want to open " & filestring & "?", vbYesNo) = vbNo Then Run "auto_open"
Run "GET_RECORD2"
'Run "SAVE"
'End If
End Sub
'==========================================================================
'- WORKSHEET 1 ROUTINE
'==========================================================================
Private Sub GET_RECORD2()
Application.ScreenUpdating = True
'ActiveSheet.Name = "PB Reports"
Range("A2:C2").Value = Array("Application", "# of reports", "Size in (kbytes)")
Open filetoopen For Input As #1
Do Until EOF(1)
Line Input #1, TextLine
If TextLine Like "Opened Input Files: Directory *" Then
outrow = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
holder = WorksheetFunction.Substitute(Mid(TextLine, 32), "]", "")
placer = Len(holder) - Len(WorksheetFunction.Substitute(holder, "\", ""))
holder = WorksheetFunction.Substitute(holder, "\", "|", placer)
holder = Right(holder, Len(holder) - InStr(1, holder, "|"))
Cells(outrow, 1).Value = holder
End If
If TextLine Like "Totals: Pages *" Then
arr = Split(TextLine, "]")
holder = arr(1)
holder = Right(holder, Len(holder) - InStr(1, holder, "["))
Cells(outrow, 2).Value = holder
End If
If TextLine Like "Input Files : Count*" Then
arr = Split(TextLine, "[")
holder = arr(2)
holder = Left(holder, InStr(1, holder, "]") - 1)
Cells(outrow, 3).Value = holder
End If
Loop
Close #1
Range("a1").Select
MsgBox "Complete"
End Sub
'============ END OF MAIN ROUTINE =========================================
Public Function leftspace(str As String) As String
Dim i As Long
Dim j As Long
i = 1
j = 1
Do
j = InStr(j, str, "\", vbBinaryCompare)
If j <= 0 Then
Exit Do
Else
i = j
j = j + 1
End If
Loop
leftspace = Right(str, Len(str) - i)
'returns the number of pages of the report as a string
End Function
rylo
Bookmarks