user4474024
user4474024

Reputation:

Prompt a user before closing PowerPoint with IF condition

I would like PowerPoint to prompt the user before PowerPoint closes if an object is still in the presentation. (An object I would have tagged).

So PowerPoint would check if that object exist and them prompt the user if it exist or close if it doesn't exist.

Hopefully this makes sense? Regards, Philippe

I think I need to use an If statement but unsure where/how I should go about it. But I am completely lost and confused!?

Private Sub Application.Presentations()
Dim oSh As Shape

For Each oSh In ActiveWindow.Selection.ShapeRange
oSh.Tags.Add "Stamp"
Next

If MsgBox("A stamp is still on the presentation. Are you sure that you want to close this book?", vbYesNo) = vbYes Then 
    Exit Sub 
Else 
    Cancel = True 
End If 

End Sub

Upvotes: 0

Views: 186

Answers (1)

John Korchok
John Korchok

Reputation: 4913

You'll need to learn how to use PowerPoint events and how to create an Add-in. Either the AutoClose VBA command or the PresentationClose event will provide the hook to hang your checking code on. Events: Make your VBA code in PowerPoint respond to events Add-ins: Create an ADD-IN with TOOLBARS that run macros

Upvotes: 1

Related Questions