Solved

VBA:  Workbook close but prompt to user to verify data upload

Posted on 2011-09-09
6
280 Views
Last Modified: 2012-05-12
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
Comment
Question by:Maliki Hassani
  • 4
  • 2
6 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 36510463
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
 

Author Comment

by:Maliki Hassani
ID: 36510499
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
 

Author Comment

by:Maliki Hassani
ID: 36510532
Okay, I got the second code to work.    Now I am working the code to run my macro.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 33

Expert Comment

by:Norie
ID: 36510698
Do you mean the macro/code for the upload?

You should just be able to call that from the BeforeClose event.
0
 

Author Comment

by:Maliki Hassani
ID: 36510706
Yes, that is what I will do
0
 

Author Comment

by:Maliki Hassani
ID: 36510737
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question