Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how can i output the file | Excel Programming | |||
Open CSV file, format data and write output to a text file. | Excel Programming | |||
Output to a file? | Excel Programming | |||
CSV output file | Excel Programming | |||
VBA help to output a file | Excel Programming |