ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel and events (https://www.excelbanter.com/excel-programming/377352-excel-events.html)

Lumpjaw

Excel and events
 
I would like to write to an event log named 'Trackers' that records a users
name and machine everytime a specific execl workbook is updated, can this be
done? How do I go about making the event log? Thanks

-lumpjaw



Roger Govier

Excel and events
 
Hi

You would need to enter something like the following in a Workbook event
before save.
This will open a file called Tracker.txt in the same folder as the
workbook, and add a row with the relevant details for you.

This must be pasted into the ThisWorkbook module, NOT in a standard
module.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

Open ThisWorkbook.Path & "\Trackers.txt" For Append As #1
Print #1, Environ("USERNAME") & "," &Environ("COMPUTERNAME") &
"," & Now
Close #1

End Sub

You can copy the code and paste it into your Visual Basic Editor
To do this,

Alt + F11 (open VBE)
Ctrl + R (open Project Explorer)
Select the file name on the left
Select This WorkBook
Paste code in Module


For more help on inserting macros
David McRitchie has lots of useful help on his site at
http://www.mvps.org/dmcritchie/excel/install.htm
http://www.mvps.org/dmcritchie/excel/getstarted.htm


--
Regards

Roger Govier


"Lumpjaw" wrote in message
...
I would like to write to an event log named 'Trackers' that records a
users name and machine everytime a specific execl workbook is updated,
can this be done? How do I go about making the event log? Thanks

-lumpjaw





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

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