![]() |
Output to .TXT-file?
Hi Guys,
I'm aware that you can make a small log to the Immediate window by using Debug.Print along the way during the execution of your code, but is it also possible to do so to a .TXT-file? TIA, |
Output to .TXT-file?
Yes. Try some version of this.
Sub LogInformation(LogMessage As String) Const LogFileName As String = "F:\Shared\CVG\Quality\Malcolms\User.txt" Dim FileNum As Integer FileNum = FreeFile ' next file number Open LogFileName For Append As #FileNum ' creates the file if it doesn't exist Print #FileNum, LogMessage ' write information at the end of the text file Close #FileNum ' close the file End Sub Private Sub Workbook_Open() LogInformation ThisWorkbook.Name & " opened by " & _ Application.UserName & " " & Format(Date, "yyyy-mm-dd") End Sub Charlotte E. wrote: Hi Guys, I'm aware that you can make a small log to the Immediate window by using Debug.Print along the way during the execution of your code, but is it also possible to do so to a .TXT-file? TIA, -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200808/1 |
Output to .TXT-file?
Worked like a charm :-)
Thanks... "Joe via OfficeKB.com" <u44989@uwe skrev i en meddelelse news:893f36308eaf1@uwe... Yes. Try some version of this. Sub LogInformation(LogMessage As String) Const LogFileName As String = "F:\Shared\CVG\Quality\Malcolms\User.txt" Dim FileNum As Integer FileNum = FreeFile ' next file number Open LogFileName For Append As #FileNum ' creates the file if it doesn't exist Print #FileNum, LogMessage ' write information at the end of the text file Close #FileNum ' close the file End Sub Private Sub Workbook_Open() LogInformation ThisWorkbook.Name & " opened by " & _ Application.UserName & " " & Format(Date, "yyyy-mm-dd") End Sub Charlotte E. wrote: Hi Guys, I'm aware that you can make a small log to the Immediate window by using Debug.Print along the way during the execution of your code, but is it also possible to do so to a .TXT-file? TIA, -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200808/1 |
All times are GMT +1. The time now is 02:00 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com