Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
How to copy 2007 excel file formula results into a 2003 Excel file Nuria Alba de Luz Excel Discussion (Misc queries) 2 July 10th 09 01:48 PM
double click excel file on the desktop excel opens but not file? JPT4266 Excel Discussion (Misc queries) 3 May 7th 09 04:24 PM
Excel 2003: doubleclick on file opens Excel window, not file. Silvy Excel Discussion (Misc queries) 2 June 29th 06 12:15 PM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
Use ADO to transfer data from open excel file to closed excel file JCanyoneer Excel Programming 1 April 1st 05 07:41 AM


All times are GMT +1. The time now is 11:32 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"