PC Review


Reply
Thread Tools Rate Thread

Determine who last modified an Excel file????

 
 
Robert Crandal
Guest
Posts: n/a
 
      7th Mar 2010
We work in a networked environment and there are only
2 users who have access to our Excel file. These 2 users
never work the same shift, so therefore only one user
will be modifying this file at any time.

My question is, is there any VBA code to determine who
was the last user to modify/save an Excel 2007 file??
Sometimes I would like to see who was the last user to
edit this file.

Thank you!


 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      7th Mar 2010
i usually just create a hidden sheet. then in the thisworkbook before close
module, add
worksheets("Hidden Sheet name").range("A1").value =environ("Username")

--


Gary Keramidas
Excel 2003


"Robert Crandal" <(E-Mail Removed)> wrote in message
news:%ODkn.71447$(E-Mail Removed)...
> We work in a networked environment and there are only
> 2 users who have access to our Excel file. These 2 users
> never work the same shift, so therefore only one user
> will be modifying this file at any time.
>
> My question is, is there any VBA code to determine who
> was the last user to modify/save an Excel 2007 file??
> Sometimes I would like to see who was the last user to
> edit this file.
>
> Thank you!
>
>


 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      7th Mar 2010
sorry, meant before save.

--


Gary Keramidas
Excel 2003


"Robert Crandal" <(E-Mail Removed)> wrote in message
news:%ODkn.71447$(E-Mail Removed)...
> We work in a networked environment and there are only
> 2 users who have access to our Excel file. These 2 users
> never work the same shift, so therefore only one user
> will be modifying this file at any time.
>
> My question is, is there any VBA code to determine who
> was the last user to modify/save an Excel 2007 file??
> Sometimes I would like to see who was the last user to
> edit this file.
>
> Thank you!
>
>


 
Reply With Quote
 
john
Guest
Posts: n/a
 
      7th Mar 2010
robert,
you could create a logfile using notepad application.

See if following is of any help:

'***********Standard MODULE(S)***********
Option Explicit

Public Function LogUserData(LogUser As String)
Dim FilePath As String
Dim FolderName As String
Dim FileName As String

On Error GoTo MakeFolder


AddData:
With ThisWorkbook

FilePath = .Path
FileName = Left(.Name, Len(.Name) - 4)

End With

FolderName = "UserLog"



Open FilePath & "\" & FileName & _
" UserLog.Log" For Append As #1

Print #1, LogUser

Close #1

Exit Function

MakeFolder:
MsgBox (Error(Err))
'folder missing so create it
MkDir ThisWorkbook.Path & "\UserLog"
Resume AddData

End Function

Sub atest()

LogUserData "Tested by " & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub

Sub OpenNotepad()

Dim FileToOpen As Variant


FileToOpen = Application _
.GetOpenFilename("Text Files (*.log), *.log", Title:="Open
UserLog File")

If FileToOpen <> False Then

Shell "notepad.exe " & FileToOpen, vbNormalFocus
End If


End Sub



'*****THISWORKBOOK MODULE****


Private Sub Workbook_Open()
LogUserData "Opened by " & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
LogUserData "Saved by " & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
LogUserData "Closed by " & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
--
jb


"Robert Crandal" wrote:

> We work in a networked environment and there are only
> 2 users who have access to our Excel file. These 2 users
> never work the same shift, so therefore only one user
> will be modifying this file at any time.
>
> My question is, is there any VBA code to determine who
> was the last user to modify/save an Excel 2007 file??
> Sometimes I would like to see who was the last user to
> edit this file.
>
> Thank you!
>
>
> .
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      7th Mar 2010
wb.BuiltinDocumentProperties("Last author")

where wb refers to the workbook

Regards,
Peter T

"Robert Crandal" <(E-Mail Removed)> wrote in message
news:%ODkn.71447$(E-Mail Removed)...
> We work in a networked environment and there are only
> 2 users who have access to our Excel file. These 2 users
> never work the same shift, so therefore only one user
> will be modifying this file at any time.
>
> My question is, is there any VBA code to determine who
> was the last user to modify/save an Excel 2007 file??
> Sometimes I would like to see who was the last user to
> edit this file.
>
> Thank you!
>
>



 
Reply With Quote
 
Robert Crandal
Guest
Posts: n/a
 
      7th Mar 2010
Thank you very much! It is much appreciated!



"john" <(E-Mail Removed)> wrote in message
news:5E1FC013-5536-4055-B7BA-(E-Mail Removed)...
> robert,
> you could create a logfile using notepad application.
>
> See if following is of any help:
>
> '***********Standard MODULE(S)***********
> Option Explicit
>
> Public Function LogUserData(LogUser As String)
> Dim FilePath As String
> Dim FolderName As String
> Dim FileName As String
>
> On Error GoTo MakeFolder
>
>
> AddData:
> With ThisWorkbook
>
> FilePath = .Path
> FileName = Left(.Name, Len(.Name) - 4)
>
> End With
>
> FolderName = "UserLog"
>
>
>
> Open FilePath & "\" & FileName & _
> " UserLog.Log" For Append As #1
>
> Print #1, LogUser
>
> Close #1
>
> Exit Function
>
> MakeFolder:
> MsgBox (Error(Err))
> 'folder missing so create it
> MkDir ThisWorkbook.Path & "\UserLog"
> Resume AddData
>
> End Function
>
> Sub atest()
>
> LogUserData "Tested by " & Application.UserName & _
> " " & Format(Now, "dd mmm yyyy hh:mm:ss")
> End Sub
>
> Sub OpenNotepad()
>
> Dim FileToOpen As Variant
>
>
> FileToOpen = Application _
> .GetOpenFilename("Text Files (*.log), *.log", Title:="Open
> UserLog File")
>
> If FileToOpen <> False Then
>
> Shell "notepad.exe " & FileToOpen, vbNormalFocus
> End If
>
>
> End Sub
>
>
>
> '*****THISWORKBOOK MODULE****
>
>
> Private Sub Workbook_Open()
> LogUserData "Opened by " & Application.UserName & _
> " " & Format(Now, "dd mmm yyyy hh:mm:ss")
> End Sub
>
>
> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
> Boolean)
> LogUserData "Saved by " & Application.UserName & _
> " " & Format(Now, "dd mmm yyyy hh:mm:ss")
> End Sub
>
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> LogUserData "Closed by " & Application.UserName & _
> " " & Format(Now, "dd mmm yyyy hh:mm:ss")
> End Sub
> --
> jb


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto determine the Modified date of your executable? Marcel Brekelmans Microsoft C# .NET 1 2nd Sep 2006 04:17 PM
How To Determine Date And Time File Was Last Modified Christopher Lusardi Microsoft VB .NET 1 26th May 2006 01:35 PM
How do I add the file last modified date into an Excel header? =?Utf-8?B?Sm9obl9Pc3Rhcg==?= Microsoft Excel Misc 3 10th Oct 2005 10:20 PM
determine last modified control Andreas Wöckl Microsoft Access Form Coding 0 4th Nov 2004 08:36 AM
Re: Excel changes file modified date when opening my add-in Bob Phillips Microsoft Excel Programming 2 15th Jul 2003 12:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 PM.