![]() |
Make sure that the excel file is still the same
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. |
Make sure that the excel file is still the same
A Workbook has a .Saved property just for this; from Help file:
Saved Property True if no changes have been made to the specified workbook since it was last saved. Read/write Boolean. Remarks If a workbook has never been saved, its Path property returns an empty string (""). You can set this property to True if you want to close a modified workbook without either saving it or being prompted to save it. -- - 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. |
Make sure that the excel file is still the same
Upon rereading, I am not sure I understood correctly with my first reply.
That reply assumed you wanted to know if an open workbook had been saved. Are you wanting to know this for a closed workbook file? If so, what could have changed it since it was last saved? -- - 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. |
Make sure that the excel file is still the same
We have a simple excel-file. We create a copy of it and just open it up with
excel and close it without changing or saving anything. If you then use a binary compare to compare the two files you see differences...and for that we could not use the hash value. we would like to know if the file we open is still the same when we last opened it...and therefore we tought about a hash value...but its not going to work if the file changes even if there is nothing changed inside... we already have an id as a custom Propertie field in the file itself (to uniqly identify the file), but we would like to have more control over it (its easy for a customer to change the custom propertie field) so we thought about a hashvalue... do you know of any other way to do that? thanks for your reply. "K Dales" wrote in message ... Upon rereading, I am not sure I understood correctly with my first reply. That reply assumed you wanted to know if an open workbook had been saved. Are you wanting to know this for a closed workbook file? If so, what could have changed it since it was last saved? -- - 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. |
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. |
Make sure that the excel file is still the same
Maybe you could save the file with a password to modify:
Under the file|SaveAs|tools menu. Then not share that password with anyone who shouldn't have access to change the file. "Jörgen Ahrens" wrote: We have a simple excel-file. We create a copy of it and just open it up with excel and close it without changing or saving anything. If you then use a binary compare to compare the two files you see differences...and for that we could not use the hash value. we would like to know if the file we open is still the same when we last opened it...and therefore we tought about a hash value...but its not going to work if the file changes even if there is nothing changed inside... we already have an id as a custom Propertie field in the file itself (to uniqly identify the file), but we would like to have more control over it (its easy for a customer to change the custom propertie field) so we thought about a hashvalue... do you know of any other way to do that? thanks for your reply. "K Dales" wrote in message ... Upon rereading, I am not sure I understood correctly with my first reply. That reply assumed you wanted to know if an open workbook had been saved. Are you wanting to know this for a closed workbook file? If so, what could have changed it since it was last saved? -- - 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. -- Dave Peterson |
All times are GMT +1. The time now is 01:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com