Maliki Hassani
asked on
VBA: Workbook close but prompt to user to verify data upload
Experts,
I have a workbook that users fill out and then press the upload data button to export their info.
I am running into an issue where some folks are just filling out the form and not hitting the upload button. Is there a way to prompt a user to upload their info when they hit the X to close out the workbook?
If so any ideas?
I have a workbook that users fill out and then press the upload data button to export their info.
I am running into an issue where some folks are just filling out the form and not hitting the upload button. Is there a way to prompt a user to upload their info when they hit the X to close out the workbook?
If so any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay, I got the second code to work. Now I am working the code to run my macro.
Do you mean the macro/code for the upload?
You should just be able to call that from the BeforeClose event.
You should just be able to call that from the BeforeClose event.
ASKER
Yes, that is what I will do
ASKER
Private Sub Workbook_BeforeClose(Cance l As Boolean)
Dim Answer2 As String
Answer2 = MsgBox("Check: Did you upload your data?", vbQuestion + vbYesNo, "Close the book")
If Answer2 = vbNo Then
Call DataExport
Else
End If
End Sub
Dim Answer2 As String
Answer2 = MsgBox("Check: Did you upload your data?", vbQuestion + vbYesNo, "Close the book")
If Answer2 = vbNo Then
Call DataExport
Else
End If
End Sub
ASKER
I found something on the net that stops the X from being pressed and a code for yes or no to close.
However, the 2nd code isn't working.
'Private Sub Workbook_BeforeClose(Cance
'Cancel = True
'End Sub
'------Second code
Private Sub Workbook_BeforeClose(Cance
If MsgBox("Are you sure", vbQuestion + vbYesNo, "Close the book") =
vbNo Then
Cancel = True
End If
End Sub