Solved

Excel macro for username of the computers

Posted on 2011-03-14
3
252 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

809 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