I have a problem with people opening backup files, then making changes and then saving the backup file.
Problems here mean that next time the original file is opened and saved it overwrites the changes made in the backup fil, plus we end up with files called "Backup_of_backup_of_filename.cdr".
I have created a sub that tells people when they're opening or moving to a tab of a backup file, which is called on the GlobalMacroStorage_WindowActivate event.
But funnily enough we still have people saving the damn file.
I can catch when people are saving the file using the GlobalMacroStorage_DocumentBeforeSave event, but cannot find a way to cancel the event so that the document can't be saved.
Does anyone know whow to do this?
Perhaps you could rig it so that they are not allowed to work on "Backup" files at all? After opening the file, trigger something to "Save As" with a "non-backup" name?
As some background, we keep our backup files (in our completed artwork directory) for a period of 3 months (anything in our in progress doesn't get deleted). The deleting of these is handled outside of CorelDRAW.
We like to keep our backup files for a short time, as sometimes someone accidentally saves something and we need to reopen to bring back some artwork or something. So I don't want to stop people from opening them, just warn them that they are opening a backup file.
However, once opened I don't want them to be able to save it though, so would prefer the ability to cancel saving.
edit: thinking about it, I could however, upon opening a backup file create a new document copy all the objects into the new file and then close the backup? would anyone know how I could do that or suggest some object methods / properties that would make my life easier rather than going through the object model documentation?
Nick Horton said:edit: thinking about it, I could however, upon opening a backup file create a new document copy all the objects into the new file and then close the backup?
That's what I was trying to suggest - not allowing them to work on a file with "Backup" at the front of the filename.
Look in the API documentation, and see what Methods are available for Document - Document class.
If you like, I can share a code snippet I already have for creating a string based on the date and time that you could use as part of the filename when automatically saving the new file.
If your backup files are occasionally saving you from grief, then I would consider using something like FreeFileSync to maintain a mirror of your artwork directory. You can set up a batch job such that when it is run, for every file deleted from or changed in the mirror, a copy of that file is saved with a timestamp appended to the filename. The "versions" can be saved in a specified folder.
If something goes wrong with a file, you can start going through the versions of it until you find one that predates the problem.
You can always delete the "versions" at a later date, when you are sure you don't need them.