VBA Before Close

Asked

Viewed 48 times

2

So what I want to do is have a message box that pops up when this Powerpoint file tries to close, saying "Did you send the data?" " Yes or no".

If you click "Yes", Excel closes, if you click "No", cancels the closing operation.

I am very novice with VBA, if you explain me step by step, I would appreciate it. I tried this code but it doesn’t work:

Private Sub PPTApp_BeforeClose(Cancel As Boolean)

    If MsgBox("Text", _

            vbQuestion + vbYesNo) = vbNo Then

        Cancel = True

    End If

End Sub

1 answer

0

Good night, Leonardo.

See if the code below helps, please:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Cancel = MsgBox("Você enviou os dados?", vbQuestion + vbYesNo) = vbNo
End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.