Wednesday, 16 January 2013

Creating a Text File and Appending Texts in the file Using VB Script

Creating a Text File and Appending Texts in the file Using VB Script:

Public Function  updateLogsFile(Information,Message)
 
strLogFilePath = "\\tstgnpappw001\IVS_ Automation\Project THOR\Statistics\Log File.txt"
 Set fso = CreateObject("Scripting.FileSystemObject")
 Time_Stamp = "| " &now& " | " &Information &" | " &Message & " |"


 If fso.FileExists(strLogFilePath) Then
    Set ts = fso.Opentextfile(strLogFilePath,8)
    ts.WriteLine ""&Time_Stamp
 Else
    Set Text = fso.CreateTextFile(strLogFilePath)
        Text.WriteLine ""&Time_Stamp
 End If


 Set ts = Nothing
 Set fso = Nothing


End Function

No comments:

Post a Comment