Author Topic: Prompt message before saving a Visio file  (Read 613 times)

0 Members and 1 Guest are viewing this topic.

Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Prompt message before saving a Visio file
« on: May 24, 2022, 11:50:27 AM »
Is there a way to prompt a user with a message (pop up) when they select the save or save as option?

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3371
    • Paul Herber's website
Re: Prompt message before saving a Visio file
« Reply #1 on: May 24, 2022, 12: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
Electronic and Electrical engineering, business and software stencils and applications for Visio -

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

Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Re: Prompt message before saving a Visio file
« Reply #2 on: May 25, 2022, 02: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