Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 358
Default Tracking Changes in a non-shared workbook

Is there any macro that could track changes in an Excel workbook without the
workbook being shared? I came across the following macro:

Dim nFile
nFile = FreeFile
Open "C:\MyLog.txt" For Append As #nFile
Print #nFile, "Workbook " & ThisWorkbook.Path & _
" opened by " & Environ("UserName") & _
" on " & Format(Now, "yyyy/mm/dd hh:mm:ss")
Close #nFile

which saves a list of when the file is accessed. But I've no idea how to
amend this to list any changes to the the workbook. In actual fact, it's
only one specific sheet that I need to track, however the nature of the file
won't allow me to share it.

Any help would be much appreciated.

Andrew.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Tracking Changes in a non-shared workbook

Maybe you could tie into the worksheet_change event and add some more text (each
cell being changed--it's address and new value) and put them into your text
file, too.

But remember that if the user closes the workbook without saving, your text file
with those changes doesn't make sense.

It might make more sense to keep track of the changes in (multiple??) worksheets
stored within the same workbook.

Something like this may give you a start if you want to do that.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim DestCell As Range
Dim LogWks As Worksheet
Dim myCell As Range
Set LogWks = Worksheets("logsheet")

If Intersect(Target, Me.UsedRange) Is Nothing Then
Exit Sub
End If

With LogWks
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

For Each myCell In Intersect(Target, Me.UsedRange).Cells
DestCell.Value = Application.UserName
With DestCell.Offset(0, 1)
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
.Value = Now
End With
DestCell.Offset(0, 2).Value = myCell.Address(0, 0)
With DestCell.Offset(0, 3)
.NumberFormat = "@"
.Value = myCell.Value
End With
With DestCell.Offset(0, 4)
.NumberFormat = "@"
.Value = myCell.Formula
End With
Set DestCell = DestCell.Offset(1, 0)
Next myCell

End Sub

Andrew wrote:

Is there any macro that could track changes in an Excel workbook without the
workbook being shared? I came across the following macro:

Dim nFile
nFile = FreeFile
Open "C:\MyLog.txt" For Append As #nFile
Print #nFile, "Workbook " & ThisWorkbook.Path & _
" opened by " & Environ("UserName") & _
" on " & Format(Now, "yyyy/mm/dd hh:mm:ss")
Close #nFile

which saves a list of when the file is accessed. But I've no idea how to
amend this to list any changes to the the workbook. In actual fact, it's
only one specific sheet that I need to track, however the nature of the file
won't allow me to share it.

Any help would be much appreciated.

Andrew.


--

Dave Peterson
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
shared workbook - shared workbook options grayed out Edward Letendre Excel Discussion (Misc queries) 0 March 3rd 10 10:47 PM
When tracking changes in excel shared workbooks, do all users see bdmedlin Excel Discussion (Misc queries) 0 December 10th 08 12:15 AM
When tracking changes in excel shared workbooks, do all users see bdmedlin New Users to Excel 0 December 8th 08 11:46 PM
Tracking Changes in Shared Worked Book Eán[_2_] Excel Worksheet Functions 0 November 19th 08 04:16 PM
Tracking Instantaneously When the Shared Excel Workbook Is Opened. DCE Excel Discussion (Misc queries) 4 May 8th 08 10:06 PM


All times are GMT +1. The time now is 11:04 AM.

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"