Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default 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,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i output the file [email protected] Excel Programming 1 January 25th 07 05:14 AM
Open CSV file, format data and write output to a text file. BristolBloos Excel Programming 1 October 18th 05 03:50 PM
Output to a file? Kevin Burton Excel Programming 4 October 4th 05 03:57 AM
CSV output file Suzanne[_5_] Excel Programming 2 March 4th 05 05:03 PM
VBA help to output a file Paula Weill Excel Programming 2 September 20th 04 02:12 PM


All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"