Make sure that the excel file is still the same
So if I now understand, you want to know if someone else (the customer) has
modified the file since the last time you opened it?
Perhaps you could do it with a hidden sheet and the Workbook_SheetChange()
Event; you could even keep a log on the hidden sheet of any changes made,
depending on how much detail you want. But at the very least you could log
the user name (Application.UserName) and date/time changed. The following is
some basic code that will keep a log of the 1000 most recent changes to a
Workbook (in practice I would add routines to detect and properly account for
multiple cell/multiple sheet ranges being changed, along with error trapping):
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim LogRange As Range
With Worksheets("CHANGES")
If Not (Sh.Name = "CHANGES") Then
Set LogRange = .Range("A1").CurrentRegion
If LogRange.Rows.Count = 1000 Then
.Range("A1").EntireRow.Delete
End If
Set LogRange = .Range("A" & .Range("A1").CurrentRegion.Rows.Count + 1)
LogRange.Cells(1, 1) = Application.UserName
LogRange.Cells(1, 2) = Now()
LogRange.Cells(1, 3) = Sh.Name
LogRange.Cells(1, 4) = Target.Address
LogRange.Cells(1, 5) = "'" & Target.Formula
End If
End With
End Sub
--
- K Dales
"Jörgen Ahrens" wrote:
Hi All
Is there a good way to test if the excel file hasn't been changed since it
was last saved?
We thought about computing the hashvalue but we noticed that when the excel
file is opened and closed without changing anything it changes its last
access date/time and also something inside the datastructure of the file.
that destroyes our hashvalue theory...
thanks for your help.
|