Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Login ID over a network
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 ? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ? . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Login ID over a network
Something I've done before is to get an open workbook to regularly
(e.g. every five minutes) query a certain database/workbook/textfile on the network for a value. If this value is set to true, the workbook closes itself. Obviously, I'm in control database/workbook/textfile and it provides me with a way of kicking someone out of the workbook with five minutes' notice! A more refined approach could check whether the current user's ID is on a list (either internal or external to the workbook) to decide whether to close itself. "Patrick" wrote in 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 ? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
SQL Server Login | Excel Discussion (Misc queries) | |||
How can i stop Network Login pop-up while downloading excel | Excel Discussion (Misc queries) | |||
Login Box help | Excel Programming | |||
Login Box | Excel Programming | |||
Copying files ...Network to Network | Excel Programming |