Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Who is using my excel file
Hi,
I am looking to find out how i can create a text file and log who is using my excel file, from when they open my file and when they close the file. I want to log this in a text file showing date and time, who is loging in to the file, and then the same info when they logout of my file. Hope someone can help me soon.. Jez. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Who is using my excel file
Here is a sample of writing a log file.
Private Sub WriteLog() ' trap error in case network not available On Error GoTo trap Dim log As String ' for the text to send to the log file Dim ff As Long ' for the link to the text file ff = FreeFile ' get a free file chammel ' create the text for the log log = Format(Date, "ddd dd-mmm-yyyy") & " BookX opened as " If ThisWorkbook.ReadOnly Then log = log & "Read Only." Else log = log & "Read Write." End If ' open the file for append 'note: if the file doesn't exist then it will be created automatically Open "X:\LogFolder\THISBOOK_LOG.TXT" For Append As ff ' send the text to the log file Print #ff, log ' then close it Close #ff trap: Err.Clear End Sub You should be able to modify it to write on opening, write on closing. Use the Workbook.Open event and the Workbook_BeforeClose event. You can get the user login name with uname = CreateObject("Wscript.Network").UserName or Public Declare Function GetUserName Lib "advapi32.dll" _ Alias "GetUserNameA" _ (ByVal lpBuffer As String, _ nSize As Long) As Long Public Function UserName() As String Dim sName As String * 256 Dim cChars As Long cChars = 256 If GetUserName(sName, cChars) Then UserName = Left(sName, cChars - 1) End If End Function -- Regards, Tom Ogilvy "Jez" wrote in message ... Hi, I am looking to find out how i can create a text file and log who is using my excel file, from when they open my file and when they close the file. I want to log this in a text file showing date and time, who is loging in to the file, and then the same info when they logout of my file. Hope someone can help me soon.. Jez. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to copy 2007 excel file formula results into a 2003 Excel file | Excel Discussion (Misc queries) | |||
double click excel file on the desktop excel opens but not file? | Excel Discussion (Misc queries) | |||
Excel 2003: doubleclick on file opens Excel window, not file. | Excel Discussion (Misc queries) | |||
opening an excel file opens a duplicate file of the same file | Excel Discussion (Misc queries) | |||
Use ADO to transfer data from open excel file to closed excel file | Excel Programming |