+ Reply to Thread
Results 1 to 2 of 2

Log User Activity to a separate file

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-21-2009
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    117

    Log User Activity to a separate file

    Hello

    I would like to keep an activity log of who opens my workbook and at what time.

    Is it possible to write to a file (CSV preferably) the following information:

    DATE, TIME, Windows Logon ID, Computer ID

    Any help is greatly appreciated!

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,480

    Re: Log User Activity to a separate file

    If they enable macros then yes.

    You would need to place a call to the logging routine in the Workbook_Open event.

    The logging routine can use simple file I/O to add a record to the file

    Thisworkbook code
    Private Sub Workbook_Open()
    
        LogOpen
        
    End Sub
    Module code
    Public Function LogOpen()
    
        Dim intUnit As Integer
        Dim strWindowsLogon As String
        Dim strComputerID As String
        Const LOG_FILE = "C:\temp\log.csv"
        
        intUnit = FreeFile
        Open LOG_FILE For Append As intUnit
        
        Write #intUnit, Now, strWindowsLogon, strComputerID
    
        Close intUnit
        
    End Function
    You need to search the forum for details on getting the logon and computer id.
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1