PresentationBeforeSave Event

Microsoft PowerPoint Visual Basic

Private Sub object_PresentationBeforeSave(ByVal Pres As Presentation, Cancel As Boolean)

object    A variable that references an object of type Application declared with events in a class module.

Pres The presentation being saved.

Cancel True to cancel the save process.

Remarks

This event is triggered as the Save As dialog box appears.

To access the Application events, declare an Application variable in the General Declarations section of your code. Then set the variable equal to the Application object for which you want to access events. For information about using events with the Microsoft PowerPoint Application object, see Using Events with the Application Object.

Example

This example checks if there are revisions in a presentation and, if there are, asks whether to save the presentation. If a user's response is no, the save process is cancelled. This example assumes an Application object called PPTApp has been declared using the WithEvents keyword.

Private Sub PPTApp_PresentationBeforeSave(ByVal Pres As Presentation, _
        Cancel As Boolean)
    Dim intResponse As Integer
    Set Pres = ActivePresentation
    If Pres.HasRevisionInfo Then
        intResponse = MsgBox(Prompt:="The presentation contains revisions. " & _
            "Do you want to accept the revisions before saving?", Buttons:=vbYesNo)
        If intResponse = vbYes Then
            Cancel = True
            MsgBox "Your presentation was not saved."
        End If
    End If
End Sub