Cancel saving document

Hi,

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.

Sub checkForBackup(ByVal FileName As String, ByVal FullName As String)

    If Left(FileName, 6) = "Backup" Then

        MsgBox "PLEASE NOTE! You have opened" & vbCrLf & "a backup version of a file." & vbCrLf & vbCrLf & _
                "DO NOT MAKE ANY CHANGES" & vbCrLf & "TO THIS FILE." & vbCrLf & vbCrLf & _
                "ALL BACKUP FILES ARE DELETED" & vbCrLf & "ON A REGULAR BASIS." & vbCrLf & vbCrLf & _
                "Please, close the file and" & vbCrLf & "open the original.", vbCritical + vbOKOnly, "WARNING! - Backup Detected"
               
    End If

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?

Regard

Nick

Parents
  • 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?

Reply
  • 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.

    Perhaps Document.SaveAs?

    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.

Children
No Data