I am trying to Append a text file with the date, time, user info, and time a macro took to run in order to generate data about a lengthy piece of code. Here is the code I have so far, but it just overwrites the original entry.
There has to be an easy way to make this work correctly. Any help would be appreciated. Thanks!
Code:
Sub CalculateRunTime_Seconds()
Dim StartTime, SecondsElapsed As Double, fso, oFile As Object, strFile_Path As String
Set fso = CreateObject("Scripting.FileSystemObject")
WinUser = Environ("USERNAME"): Debug.Print "WinUser = " & WinUser
Set oFile = fso.CreateTextFile("H:\Beta 1,3 Logs.txt")
strFile = "H:\Beta 1,3 Logs.txt"
'Remember time when macro starts
StartTime = Timer
'*****************************
'Insert Your Code Here...
'Call "ModuleName"."Procedure Name"
Call FillDownList.FillDownList
'*****************************
'Determine how many seconds code took to run
SecondsElapsed = Round(Timer - StartTime, 2)
Set fso = Nothing
Set oFile = Nothing
Open strFile For Append As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL]
Write [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , "Time: " & Now & vbNewLine & " User: " & WinUser & vbNewLine & "Raw Data Import took " & SecondsElapsed & " seconds to complete."
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL]
Debug.Print "This code ran successfully in " & SecondsElapsed & " seconds"
End Sub