Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
My program has a macro that should normally be executed before the user
closes the file. The macro transfers data to a destination file, but there are times where the user forgets or neglects to run it. I would like to have a warning message display only when the user attempts to close the file and the macro has not been run. I don't want to go as far as forcing the macro as there are times when the file is opened and worked on and then may be aborted for a legit reason. Any suggestions? |
#2
![]() |
|||
|
|||
![]()
You would need an event macro to be placed in the ThisWorkbook code module:
Something like (untested): Private Sub Workbook_BeforeClose(Cancel As Boolean) If MsgBox("Do you want to run the XXX macro?", _ vbYesNo + vbQuestion, "Reminder!") = vbYes Then Cancel = True XXX End If End Sub where "XXX" is the name of the macro. This is plain vanilla; you could add error-handling, testing whether the macro has already been run, etc. -- Vasant "Lambtwo" wrote in message news:O1f7f.297503$tl2.119111@pd7tw3no... My program has a macro that should normally be executed before the user closes the file. The macro transfers data to a destination file, but there are times where the user forgets or neglects to run it. I would like to have a warning message display only when the user attempts to close the file and the macro has not been run. I don't want to go as far as forcing the macro as there are times when the file is opened and worked on and then may be aborted for a legit reason. Any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding an error message at close of file when criteria are met | Excel Discussion (Misc queries) | |||
What is the VBA code to delete a sheet without warning message? | Excel Discussion (Misc queries) | |||
Getting message can't save all data in excel xls file | Excel Discussion (Misc queries) | |||
Read Text File into Excel Using VBA | Excel Discussion (Misc queries) | |||
Error Message appearing when saving a file | Excel Discussion (Misc queries) |