Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Logging users accessing a spreadsheet

Looking for a way to log (on a sheet within a workbook) all users that
access the spreadsheet and when.

Is this possible using wither VBA or other method?

Many thanks.

DT


  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,824
Default Logging users accessing a spreadsheet

Do the users have access to a share that they can write to?

If yes, you could have a macro that adds a line to a tab delimited text file
when they open the file (macros must be enabled, though).

Rightclick on the excel icon to the left of the File option (on the worksheet
menubar). Select view code and paste this into the code window:

Option Explicit
Private Sub Workbook_Open()

Dim LogDir As String
Dim LogFile As String
Dim myFileNum As Long
Dim testDir As String

LogDir = "\\servername\sharename\foldername"
LogDir = "C:\my documents\excel"
LogFile = LogDir & "\log.txt"

testDir = ""
On Error Resume Next
testDir = Dir(LogDir, vbDirectory)
On Error GoTo 0

If testDir = "" Then
'not connected or spelling error!
Exit Sub
End If

myFileNum = FreeFile()
Open LogFile For Append As #myFileNum
Print #myFileNum, ThisWorkbook.FullName & vbTab _
& Application.UserName & vbTab & fOSUserName & Now
Close #myFileNum

End Sub

Then right click on the project (hit ctrl-r to see it if its not shown). Select
Insert, then Module.

Paste this in:

Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX < 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function

=====
When you want to view the log, just open excel and do File|open--choose
delimited by tab when you see the import wizard.

DT wrote:

Looking for a way to log (on a sheet within a workbook) all users that
access the spreadsheet and when.

Is this possible using wither VBA or other method?

Many thanks.

DT


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error when accessing a spreadsheet Nat Excel Worksheet Functions 1 May 13th 08 11:13 PM
Multiple users for spreadsheet Dirk_Bob Excel Discussion (Misc queries) 1 June 10th 07 04:58 AM
Access data on spreadsheet without accessing the file?... Dan Brimley Excel Discussion (Misc queries) 6 May 25th 07 07:27 AM
Access data on spreadsheet without accessing the file?... Dan Brimley Excel Worksheet Functions 6 May 25th 07 07:27 AM
Users stuck, not logging out of shared workbook Peter Excel Discussion (Misc queries) 1 January 4th 07 02:01 PM


All times are GMT +1. The time now is 04:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"