![]() |
Text File
How can I make an Excel file create a text file ( only if the text file is not already created ) and keep adding details into that text file ( what is written across say 1 row thats made up of date, time, etc etc ) so I can look back in the text file as a kind of history file. This could be done every time the Excel file changes or say only when the file has been opened so it keeps a log of file opening and saving times etc??? - If this is possible, I could provide a more detailed explanation of what I need - Thanks -- sparx ------------------------------------------------------------------------ sparx's Profile: http://www.excelforum.com/member.php...o&userid=16787 View this thread: http://www.excelforum.com/showthread...hreadid=535345 |
Text File
You would need to write some VB code to do that, or you could use the Track Changes option in Excel. Select Tools, Track Changes, and select your options. Hope this helps -- sparx Wrote: How can I make an Excel file create a text file ( only if the text file is not already created ) and keep adding details into that text file ( what is written across say 1 row thats made up of date, time, etc etc ) so I can look back in the text file as a kind of history file. This could be done every time the Excel file changes or say only when the file has been opened so it keeps a log of file opening and saving times etc??? - If this is possible, I could provide a more detailed explanation of what I need - Thanks -- Bryan Hessey ------------------------------------------------------------------------ Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059 View this thread: http://www.excelforum.com/showthread...hreadid=535345 |
Text File
Here is a start.
Sub LogToTextFile() Const ForAppending = 8 Set fso = CreateObject("Scripting.FileSystemObject") Set report = fso.OpenTextFile("C:\Test\xlrprt.txt", ForAppending, True, 0) report.WriteLine Sheets(1).Cells(1, 1).Value report.Close Set report = Nothing Set fso = Nothing End Sub The sub above assumes that the folder "C:\Test" exists. It will create the text file xlrprt.txt in that folder if it doesn't already exist. It will add a line to the end of the text file that in this example is the value found in Cell A1 on Sheet1. It sounds like you want this sub to be triggered by an event rather than the way I show it. I'd probably go with the window activate event or something similar but it kind of depends on the details of what you want to record in the text file. Steve "sparx" wrote in message ... How can I make an Excel file create a text file ( only if the text file is not already created ) and keep adding details into that text file ( what is written across say 1 row thats made up of date, time, etc etc ) so I can look back in the text file as a kind of history file. This could be done every time the Excel file changes or say only when the file has been opened so it keeps a log of file opening and saving times etc??? - If this is possible, I could provide a more detailed explanation of what I need - Thanks -- sparx ------------------------------------------------------------------------ sparx's Profile: http://www.excelforum.com/member.php...o&userid=16787 View this thread: http://www.excelforum.com/showthread...hreadid=535345 |
Text File
Thanks for your reply - your VBA code works a treat - only thing is for it to copy more than only one cell, lets say approx A1:T1 ( 20 columns ) but all on one row. I think I might be able to run your vba in the workbook section so it copies a log of file use. -- sparx ------------------------------------------------------------------------ sparx's Profile: http://www.excelforum.com/member.php...o&userid=16787 View this thread: http://www.excelforum.com/showthread...hreadid=535345 |
All times are GMT +1. The time now is 09:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com