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?

Maliki HassaniAsked:
Who is Participating?
 
NorieConnect With a Mentor VBA ExpertCommented:
You could add code in the workbook's close event to either do the upload or prompt the user to do it.

For that you'd need some way to check if the upload has been done or not.
0
 
Maliki HassaniAuthor Commented:
Well my upload verifies if the tickID is a duplicate already..  I just need to know a way to have the popup message show everytime the X is pressed.

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(Cancel As Boolean)
'Cancel = True
'End Sub

'------Second code
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Are you sure", vbQuestion + vbYesNo, "Close the book") =
vbNo Then
Cancel = True
End If
End Sub
0
 
Maliki HassaniAuthor Commented:
Okay, I got the second code to work.    Now I am working the code to run my macro.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
NorieVBA ExpertCommented:
Do you mean the macro/code for the upload?

You should just be able to call that from the BeforeClose event.
0
 
Maliki HassaniAuthor Commented:
Yes, that is what I will do
0
 
Maliki HassaniAuthor Commented:
Private Sub Workbook_BeforeClose(Cancel 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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.