Solved

Excel macro for username of the computers

Posted on 2011-03-14
3
251 Views
Last Modified: 2012-06-27
Dear experts,
I would like to learn who has opened my excel file in the company where we use a network and every computer has a username?
I need a macro for this.
do you know one?
0
Comment
Question by:Braveheartli
3 Comments
 
LVL 17

Expert Comment

by:sgsm81
ID: 35126633
0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 500 total points
ID: 35126677
If you add this code to the ThisWorkbook module it will append records to a text file (log.txt" in the same path as the file is stored

It will write
System Log On, PC Name, Time

You can change the log file path, ie to write to z:\temp where z is a network drive

Open "z:\temp\usage.log" For Append As #1

Cheers

Dave
Private Sub Workbook_Open()
    Open ThisWorkbook.Path & "\log.txt" For Append As #1
    Print #1, Environ("username"), Environ("computername"), Now
    Close #1
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 35126739
Dear brettdj,
your answer is great,
thank you very much,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now