ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   On opening an excel file (https://www.excelbanter.com/excel-programming/271261-re-opening-excel-file.html)

John Wilson

On opening an excel file
 
pcor,

One way.....
Original code from John Walkenbach

Open ThisWorkbook.Path & "\Logs\GB.log" For Append As #1
Print #1, Application.UserName, Now, "Opened"
Close #1

The above explained (modify at will):
1st Line - Opens a text file named GB.log in a subdirectory named
"Logs" underneath the current directory that the workbook was saved in.
2nd Line - Append the UserName, Date & Time and the comment "Opened"
to the GB.log file
3rd Line - close and save the GB.log file.

Notes....
The directory or subdirectory that you're creating the file in must exist
but the file itself doesn't have to exist (it will be vreated the first time
and appended to each subsequent time).
Place the above code in the Workbook_Open Event or in a regular module
and name the sub Auto_Open().

John

pcor wrote:

I want the program to write the date and time to a file on disk everytime
this Excel file is opened.
Help please.

--
Norton Virus checker 2003 says this email is clean




All times are GMT +1. The time now is 02:24 PM.

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