I’m trying to find a way to archive previous versions of Excel and Word files as they are saved; as in, when a file is edited and then saved, the *original* version of the file is copied to another directory, so that we have a running history of changes. This needs to apply to every file that is opened, which I think means using application events — and leads me onto very shaky programming ground, as I’ve never come to grips with events yet and don’t have a good sense of the possibilities. I’m hoping someone here can tell me if I’m trying to do the impossible.
It seems to me there are two possible (?) ways of going about solving this:
1. At the point in time when the file is saved, use the BeforeSave event to make a copy of the original file to an archive directory.
2. At the point in time when the file is opened, use the Open event to make a temporary copy of it; when the file is saved, move the temporary copy to an archive directory. If the file is not saved, delete the temporary copy.
Option 1 looks more efficient, because nothing is done at all if the file is never saved. But it depends when the BeforeSave event fires, and if it can truly make a copy of the original file without edits. I think that it’s possible with Word (because it makes its own temporary copy of the file for editing, and then copies it back over the original file at save), but I’m not familiar enough with Excel to be confident in how it manages files — and Excel is the more important program in this case.
Option 2 seems to me more likely to get a true copy of the original file, because it makes a copy before the file can be edited — but there’s extra overhead involved because it makes a copy every single time a file is opened, whether it is saved or not. Then those temporary files always have to be dealt with, either by moving or deletion or whatever.
Has anyone ever done anything like this? Does either of these methods seem more likely to work — or am I overlooking something better? I’m really clueless at this point, so any guidance would be greatly appreciated.
Thanks!