Solved

Excel macro for username of the computers

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

744 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

11 Experts available now in Live!

Get 1:1 Help Now