Prompt message before saving a Visio file

Started by Crazy Squirrel, May 24, 2022, 04:50:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Crazy Squirrel

Is there a way to prompt a user with a message (pop up) when they select the save or save as option?

Paul Herber

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
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Crazy Squirrel

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