Hi All,
Thanks in advance for any help offered !
I am new to programming and need to gather some applications statistics. I basically need to read a log file and search on some strings to gather the required data.
Sample of Log file below:
GatewayLogFilePic.jpg
I have the created code below which outputs some information but I don't know what should be my next steps. Please advise.
---------------------------------------------------------------------------------------------------------------------------------------------------
[SIZE=4]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("a1").Select
Open filetoopen For Input As #1
Do Until EOF(1)
Line Input #1, TextLine
If TextLine Like "Opened Input Files: Directory *" Then
ActiveCell.Value = Mid(TextLine, 32)
ActiveCell.Offset(0, 1).Select
End If
If TextLine Like "Totals: Pages *" Then
ActiveCell.Value = TextLine
ActiveCell.Offset(1, -1).Select
End If
If TextLine Like "*ScriptSetError: ErrorNumber *" Then
ActiveCell.Offset(1, -1).Select
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
---------------------------------------------------------------------------------------------------------------------------------------------------
Bookmarks