Last active
April 26, 2017 16:56
-
-
Save 0x4a/410e1c3df4c2f1bb2e430fa73d4ab2a5 to your computer and use it in GitHub Desktop.
Excel VBA log-to-file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Const VERBOSE As Boolean = false | |
Private Function log(text as String) | |
Debug.Print text | |
If VERBOSE Then | |
Dim n As Integer | |
n = FreeFile() | |
Dim File As String | |
File = ActiveWorkbook.Path & "\debug.txt" | |
If Dir(File) = "" Then | |
Open File For Output As #n | |
Close #n | |
End If | |
Open File For Append As #n | |
Print #n, "[" & Format(Now, "YYYY-MM-DD hh:mm:ss") & "] " & text | |
Close #n | |
End If | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment