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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture user name & PC number

Status
Not open for further replies.

raccess

Programmer
Dec 31, 2002
91
US
Hi,

I have one shared MS Excel file on my PC. Is there way that i can know who is accessing my file from which PC in network?

Any kind of help - idea ?

Thanks in Advance,

RV
 
You can probably get the information from the environment variables. For example, on my computer I can get the following variables:
USERNAME
COMPUTERNAME
USERDOMAIN
You access them as, for example, environ("USERNAME").
To see all of them, run this from the immediate window:

i=1:do while environ(i)<>&quot;&quot;:?i,&quot; &quot;,environ(i):i=i+1:loop

Good luck
Rob
[flowerface]
 
Thanks for your quick reply.

but how i can see this in Excel?

is it possible to generate any kind of log file. when anyone access this shared file it will write that user name & his computer name in to any text file or withing that excel but hidden to users?

Thanks
 
Yes, you would have to put a workbook_open event handler on the code page for ThisWorkbook (do you know how to do this?), and from within that sub write an entry to your log file, e.g.

sub workbook_open()
open ThisWorkbook.path & &quot;\logfile.txt&quot; for append as #1
print#1, now(),environ(&quot;USERNAME&quot;)
close#1
end sub
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top