ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Record who opens a excel file (https://www.excelbanter.com/excel-discussion-misc-queries/126413-record-who-opens-excel-file.html)

louiscourtney

Record who opens a excel file
 
Is it possible to record who opens and saves something to the excel file??

Gary''s Student

Record who opens a excel file
 
Store this small macro in ThisWorkbook code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Set r = Workbooks("B1.xls").Sheets("S1").Range("A1")
r.Value = Environ("UserName")
End Sub


change the workbook and sheet names to suit you. If you are not familiar
with VBA, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm
--
Gary's Student
gsnu200701


"louiscourtney" wrote:

Is it possible to record who opens and saves something to the excel file??


RCW

Record who opens a excel file
 
You can create a separate text file with a similar name that records the
Excel and system log in names and the time the workbook was opened by pasting
this into a standard VBA module.

The Print#1, line ends in Now. You may need to fix that if it gets split
into two lines in the reply.

Sub Auto_Open()

' Use as part of an Auto_Open macro
' Change both occurances of C:\myExcelBackups to the desired
' path location for the File Use Log -i.e. a network drive?
' A text file will show the name and time of everyone who
' opens the workbook.

Application.DisplayAlerts = False
Dim FileUser As String
Dim FileUserDocFILE As String

FileUser = ActiveWorkbook.Name

On Error Resume Next
MkDir "C:\myExcelBackups"
FileUserDocFILE = "C:\myExcelBackups\" & FileUser & " Log.txt"
On Error GoTo 0

Open FileUserDocFILE For Append As #1
Print #1, Application.UserName & Environ("username") & " Opened " &
ActiveWorkbook.Name & " at " & Now
Close #1

Application.DisplayAlerts = True

End Sub

"louiscourtney" wrote:

Is it possible to record who opens and saves something to the excel file??



All times are GMT +1. The time now is 05:46 AM.

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