Make a log of users

dgrimm

Board Regular
Joined
Sep 17, 2007
Messages
159
Is there a feature in excel or an easy macro that can be used to maintain a log of persons using a file and the date that they use it each time.

Thank you

Dave
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this in the ThisWorkbook module.
NB Application.UserName is dependant on how user names have been installed on computers.

Code:
[COLOR=darkblue]Private[/COLOR] [COLOR=darkblue]Sub[/COLOR] Workbook_Open()
   [COLOR=darkblue]Dim[/COLOR] fNum [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]
 
   fNum = FreeFile
   [COLOR=darkblue]Open[/COLOR] "[COLOR=red]C:\myFile_Log.txt[/COLOR]" [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Append[/COLOR] [COLOR=darkblue]As[/COLOR] #fNum
   [COLOR=darkblue]Print[/COLOR] #fNum, "Opened: " & Application.UserName _
                        & vbTab & Now
   [COLOR=darkblue]Close[/COLOR] #fNum
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0
Bertie -

Quick question, the now that you have in your routine is it converted to a value by the print command or will it change to now each time this sheet is accessed??

Thanks
Dave
 
Upvote 0
The Now() function is the computer system date/time stampat the time the code is executed.

You can change the format, i.e.,

Format(Now,"dd/mm/yyyy hh:mm:ss")
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top