ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I log everytime an excel workbook is opened? (https://www.excelbanter.com/excel-programming/318881-how-do-i-log-everytime-excel-workbook-opened.html)

bmarks

How do I log everytime an excel workbook is opened?
 
I have user name and password applied to a workbook I'm creating. Anyone
know the basic code used to log everytime a user accesses the workbook and
when?

Harald Staff

How do I log everytime an excel workbook is opened?
 
Hi

Goes in the ThisWorkbook module of the file:

Private Sub Workbook_Open()
Dim iFNum As Integer
iFNum = FreeFile
Open "C:\Temp\Log.txt" For Append As #iFNum
Print #iFNum, ThisWorkbook.FullName & " opened " & _
Now & " by " & Environ("username") & " on pc " & _
Environ("computername")
Close #iFNum
End Sub

Change filepath to fit, it should be on a network drive with write access
for everyone (a thing that doesn't seem to exist anymore in
corporations...)

HTH. Best wishes Harald

"bmarks" skrev i melding
...
I have user name and password applied to a workbook I'm creating. Anyone
know the basic code used to log everytime a user accesses the workbook and
when?





All times are GMT +1. The time now is 06:25 AM.

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