Visio Guy

Visio Discussions => General Visio => Topic started by: Crazy Squirrel on May 24, 2022, 04:50:27 PM

Title: Prompt message before saving a Visio file
Post by: Crazy Squirrel on May 24, 2022, 04:50:27 PM
Is there a way to prompt a user with a message (pop up) when they select the save or save as option?
Title: Re: Prompt message before saving a Visio file
Post by: Paul Herber on May 24, 2022, 05:28:38 PM
If the event can be caught using VBA then yes, but the document will have to be saved with the macro-friendly file extension: .vsdm. And macros would have to be enabled at the user-end as well, not something you can control. However, if the file was saved with the non-macro-friendly extension: .vsdx the all the code will be lost and the prompt will never occur.
There are events for:
Document.BeforeDocumentSave
Document.BeforeDocumentSaveAs
Title: Re: Prompt message before saving a Visio file
Post by: Crazy Squirrel on May 25, 2022, 07:24:53 AM
Thanks Paul.  I have macros in the document already and when the user opens it, they click on a message to enable content.  Would you happen to have the VBA code? I found this to use as a basic start -
Private Sub Form_BeforeUpdate(Cancel As Integer)
   Dim strMsg As String
   Dim iResponse As Integer

   ' Specify the message to display.
   strMsg = "Do you wish to save the change?" & Chr(10)
   strMsg = strMsg & "Click Yes to Save or No to Discard changes."

   ' Display the message box.
   iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
   
   ' Check the user's response.
   If iResponse = vbNo Then
   
      ' Undo the change.
      DoCmd.RunCommand acCmdUndo

      ' Cancel the update.
      Cancel = True
   End If
End Sub