Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

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?

0
Maliki Hassani
Asked:
Maliki Hassani
  • 4
  • 2
1 Solution
 
NorieCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
NorieCommented:
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now