Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey all.
I am working on a log-like mechanism in VBA. I programmed the following sub: Sub CreateLog() Datum = Date Tijd = Time Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.CreateTextFile("H:\test " + Cstr(Datum) + ".txt", True) a.WriteLine("The process begun @ " + Cstr(Tijd) + " on " + Cstr(Datum)) a.close End Sub But this overwrites the textfile over and over again. I would like it to open the existing textfile, and add a new line (the same line as above) on top of the other line(s) The result would be a summary of lines in one textfile. Everytime this macro is activated i would like to be an line added. is this possible? if yes, please could anyone help me? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Silencer,
Yust need to append the text to the existing text file. Const ForAppending = 8 Set objTextFile = fs.OpenTextFile (strDirectory & strFile, ForAppending, True) objTextFile.WriteLine "text" Best Regards, Agnieszka |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You might be able to adapt the following, it creates a login record in a
text file (appends each time the workbook is opened). Does not use FSO scripting either! Private Sub Workbook_Open() Open ThisWorkbook.Path & "\TrackUsage.log" For Append As #1 Print #1, Application.UserName, Now, "Opened" Close #1 End Sub -- Cheers Nigel "Silencer116" wrote in message oups.com... Hey all. I am working on a log-like mechanism in VBA. I programmed the following sub: Sub CreateLog() Datum = Date Tijd = Time Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.CreateTextFile("H:\test " + Cstr(Datum) + ".txt", True) a.WriteLine("The process begun @ " + Cstr(Tijd) + " on " + Cstr(Datum)) a.close End Sub But this overwrites the textfile over and over again. I would like it to open the existing textfile, and add a new line (the same line as above) on top of the other line(s) The result would be a summary of lines in one textfile. Everytime this macro is activated i would like to be an line added. is this possible? if yes, please could anyone help me? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey Agnieszka and Nigel
Thanks for your quick responds! i'll try it right away! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
DDE Logging Data Loss in Excel | Excel Discussion (Misc queries) | |||
Live DDE Data Logging | Excel Discussion (Misc queries) | |||
Logging Data Single Input | Excel Programming | |||
Copy data from textfile, paste and transpose to sheet2 | Excel Programming | |||
Logging data from a web query | Excel Programming |