Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Determine who last modified an Excel file????

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!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Determine who last modified an Excel file????

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" wrote in message
...
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!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Determine who last modified an Excel file????

sorry, meant before save.

--


Gary Keramidas
Excel 2003


"Robert Crandal" wrote in message
...
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!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Determine who last modified an Excel file????

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!


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Determine who last modified an Excel file????

wb.BuiltinDocumentProperties("Last author")

where wb refers to the workbook

Regards,
Peter T

"Robert Crandal" wrote in message
...
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!






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Determine who last modified an Excel file????

Thank you very much! It is much appreciated!



"john" wrote in message
...
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
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
Macro to determine row of page break on modified presentation sheet? pallaver Excel Discussion (Misc queries) 2 July 21st 08 06:05 AM
Excel File Open Box - want Date Modified Titian Excel Discussion (Misc queries) 2 February 26th 06 08:25 AM
Determine if cell was modified by Enter , Paste or Delete Randy Excel Programming 3 April 30th 05 04:17 PM
How to determine which button was clicked on the modified right-click menu Patrick Choi Excel Programming 1 September 1st 03 02:07 PM
Excel changes file modified date when opening my add-in Bob Phillips[_5_] Excel Programming 2 July 15th 03 12:25 AM


All times are GMT +1. The time now is 11:30 PM.

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

About Us

"It's about Microsoft Excel"