ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add data to a text file (https://www.excelbanter.com/excel-programming/319100-add-data-text-file.html)

P

Add data to a text file
 
Hello Experts,

I am interested to write contents of excel worksheet to a system file.

From MSDN i fould reference to filesystemobject in VBScript. But i am not
able to access "fileSystemObject" in Excel.

Any solution.

I would like to append to a log.txt to reflect the usage of the excel
Workseet and a a snapshot of performed taks.


--
Purnank




Tom Ogilvy

Add data to a text file
 
Here is some sample code previously posted by Patrick Malloy

Private Sub WriteLog()
' trap error in case network not available
On Error GoTo trap
Dim log As String ' for the text to send to the log file
Dim ff As Long ' for the link to the text file
ff = FreeFile ' get a free file chammel
' create the text for the log
log = Format(Date, "ddd dd-mmm-yyyy") & " BookX opened as "
If ThisWorkbook.ReadOnly Then
log = log & "Read Only."
Else
log = log & "Read Write."
End If
' open the file for append
'note: if the file doesn't exist then it will be created automatically
Open "X:\LogFolder\THISBOOK_LOG.TXT" For Append As ff
' send the text to the log file
Print #ff, log
' then close it
Close #ff

trap: Err.Clear


End Sub


--

Regards,

Tom Ogilvy



"P" wrote in message
...
Hello Experts,

I am interested to write contents of excel worksheet to a system file.

From MSDN i fould reference to filesystemobject in VBScript. But i am not
able to access "fileSystemObject" in Excel.

Any solution.

I would like to append to a log.txt to reflect the usage of the excel
Workseet and a a snapshot of performed taks.


--
Purnank







All times are GMT +1. The time now is 01:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com