Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracking who has opened a workbook 2

Status
Not open for further replies.

kitackers

MIS
Apr 16, 2004
33
GB
I know it's possible and very simple to do in Access, but can anyone tell me if there is a way to track who has opened up a workbook with times and dates.

I've been scratching my head for a while, but just can't work it out!!
 
You could open the "track changes" feature if you have XP or higher or I have posted code to do this before - have a search within this forum...

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
It's not changes that I want to track, as this is a workbook that doesn't get edited, it's just tracking who has opened the wirkbeek and when.

What I want to do is see whether a workbook is being viewed by those who it is available to without asking people.

Cheers
 
go to VBE
Press F1
Type "Event"
Read help files on workbook OPEN event

You can get the user who has opened the workbook with

myUser = environ("username")

You can search this forum for countless examples of how to write to a text file or a seperate sheet in the workbook

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
You can retrieve the Windows username by using the
Environ("USERNAME") variable.
Time and Date are obviously just Time() and Date().

The problem would be where to store the details if you don't want to have a spare worksheet with this information.

I would recommend exploring the Custom Document Properties which you can access from File, Properties, Custom...

Good luck!
sugarflux
 
I have a need to do the exact same thing. If user opens with disabled macors all they see is a sheet asking them to quit and enable macros. When enabled, the open process unhides all of the 'very hidden' sheets. The workbook open process then writes out the user info to a text file I have elsewhere on the network.

Code:
Sub monitor_use()

Dim byt_fo As Byte

    byt_fo = FreeFile
    Open TRACK_FILE For Append As #byt_fo
    Print #byt_fo, "Opened by : " & funcs.ReturnUserName & " on " & Now    
    Close #byt_fo
    
End Sub

Function ReturnUserName() As String

Dim str_r As String * 255
Dim lng_s As Long
Dim str_t As String

    str_t = ""
    
    lng_s = GetUserName(str_r, 255)
    lng_s = InStr(1, str_r, Chr(0))
    
    If lng_s > 0 Then
        str_t = Left(str_r, lng_s - 1)
    Else
        str_t = str_r
    End If

    ReturnUserName = UCase(Trim(str_t))

End Function
When they quit, the workbook close process sets all sheets to 'very hidden' barring the enable macros warning.

HTH
smiley_pc.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top