Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Need User Name

Is it possible to get "User Name" variable to see who used the Excel sheet
last time?

I have many sheets which are shared be many people, but somebody is messing
up and I cannot figure out where the problem is coming from.

I would write macro to record User Name and time before Save, but I need
that variable.

Thank you for your help

Jan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Need User Name

Try this event macro in the workbook code area:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("Sheet3").Activate
n = Application.WorksheetFunction.Max(2, Cells(Rows.Count, 1).End(xlUp).Row
+ 1)
Cells(n, 1).Value = Environ("Username")
Cells(n, 2).Value = Now
End Sub


--
Gary''s Student - gsnu200836


"Jan Nademlejnsky" wrote:

Is it possible to get "User Name" variable to see who used the Excel sheet
last time?

I have many sheets which are shared be many people, but somebody is messing
up and I cannot figure out where the problem is coming from.

I would write macro to record User Name and time before Save, but I need
that variable.

Thank you for your help

Jan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need User Name

You can get the "Last Author" built in document property. This is the
User Name as entered in the "User name" item on the General tab of the
Options dialog (Tools menu, Options item). This can be changed by the
user, so while it may well suffice for most purposes, it shouldn't be
relied upon for security and audit purposes.

You could add a Custom Document Property containing the user's logon
ID. In the ThisWorkbook module, paste the following code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
On Error Resume Next
Dim CustomDocProps As Office.DocumentProperties
Set CustomDocProps = ThisWorkbook.CustomDocumentProperties
CustomDocProps.Add _
Name:="Last User ID", _
LinkToContent:=False, _
Type:=msoPropertyTypeString, _
Value:=Environ("UserName")
End Sub


This will create a custom property named "Last User ID" and give it a
value of the user's logon name. This property will be visible and
changeable in the Properties dialog (File menu, Properties), so the
dishonest user could circumvent it with a bit of effort.

Another way is to create a hidden defined name with the user's logon
ID.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
ThisWorkbook.Names.Add Name:="LastLogonID", _
RefersTo:=Environ("UserName"), _
Visible:=False
End Sub

This, too, could be circumvented by a skilled user. There really isn't
any fool-proof way to ensure that the UserName value can't be spoofed
by a skilled user. That said, any of these methods may well be "good
enough" for general use.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Sun, 8 Mar 2009 09:57:06 -0600, "Jan Nademlejnsky"
wrote:

Is it possible to get "User Name" variable to see who used the Excel sheet
last time?

I have many sheets which are shared be many people, but somebody is messing
up and I cannot figure out where the problem is coming from.

I would write macro to record User Name and time before Save, but I need
that variable.

Thank you for your help

Jan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Need User Name

Thanks Gary and Chip. I will try that tomorrow.

Jan

"Jan Nademlejnsky" wrote in message
...
Is it possible to get "User Name" variable to see who used the Excel sheet
last time?

I have many sheets which are shared be many people, but somebody is
messing up and I cannot figure out where the problem is coming from.

I would write macro to record User Name and time before Save, but I need
that variable.

Thank you for your help

Jan



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically add a textbox to a user form based on user requireme Brite Excel Programming 4 April 7th 07 11:37 PM
User form ComboBox Items: Remember user entries? [email protected] Excel Programming 0 March 29th 07 06:41 PM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
User Defined Functions - Help Text - Make it Easy for the User Andibevan[_2_] Excel Programming 4 March 17th 05 09:51 AM
How to: Make user click End User License Agreement acceptance jasonsweeney[_21_] Excel Programming 7 January 30th 04 01:41 AM


All times are GMT +1. The time now is 05:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"