Login ID over a network
As a quick fix (if it is a workbook) you could put a macro
in the Workbook_Open event that would write the User to a
central log log.
If you copy the below code in the code section of
ThisWorkbook it will illustrate what I mean. I tied the
rcording to Open and close events but you could also use
the save event.
It's not exactly what you are looking for but may provide
others with some additional ideas.
Felix
Private Sub Workbook_Open()
WriteLog ("Open")
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
WriteLog ("Close")
End Sub
Function WriteLog(ActionType As String)
Dim FileNum1, OutFile
On Error Resume Next
FileNum1 = FreeFile
OutFile = ThisWorkbook.Path + "\Users.log"
'Create the result file if not already there
Open OutFile For Append As FileNum1
Print #FileNum1, ActionType + "|" + _
UserLogon + "|" + _
ThisWorkbook.Name; "|" + _
CStr(Now())
Close #FileNum1
End Function
Function UserLogon()
Dim objNet
Set objNet = CreateObject("WScript.NetWork")
UserLogon = objNet.UserName
End Function
-----Original Message-----
Can anybody do this ?
Imagine a file sitting on a network drive (this file
could
be an Excel Workbook or a text CSV file). It can be
accessed by anybody in the business.
Often people will go into this file (not ReadOnly) which
causes a problem because somebody somewhere might want to
update or overwrite it completely.
I want a macro that will check the status of this file ,
by returning not Just the Excel Name of a user whose
inside it, but also their login ID.
I understand using a shared workbook is an option to
solving the above problem , but this isnt always
possible.
I also have the API code for returning the login from a
local machine.
So how do I get the login of a user in a workbook/CSV
file
on a network drive ?
.
|