Solved

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

Posted on 2011-09-09
6
275 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now