Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close workbook with "Cancel=TRUE" in the BeforeClose()"
I added cVBA code in the "BeforeClose()" event to check to ensure use would enter mandatory data before existing. If they don't, I keep th excel open by using the "Cancel=true" command." I recently found out that users use the Windows Tasks Manager t terminate the Excel even they know that there are mandtory fields dat required. Now, when I run codes data collection VBA codes in my "Master spreadsheet to collect data from those returned spreadsheets, I ra into trouble. In my VBA code, after openning the workbook and foun mandatory data is missing, I stop processing for the opened spreadshee but I CANNOT open it because of the "BeforeClose()'s cancel=true statement. Can someone please tell me how can I close this spreadsheet (one on with the Cancel=True statment) in my "Master" spreadsheet's VBA ? Here is log highlevel pseudo-code: MasterSpreadsheet { Open "DataSpreadsheet" Check for Mandatory data if ok then process data and close :) "DataSpreadsheet" else close "DataSpreadsheet" - NOW I cannot clos it because I have a "Cancel=TRUE" statement inside which found tha Mandatory data is missing. endif -- Welli ----------------------------------------------------------------------- Wellie's Profile: http://www.excelforum.com/member.php...fo&userid=1537 View this thread: http://www.excelforum.com/showthread.php?threadid=26987 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close workbook with "Cancel=TRUE" in the BeforeClose()"
Application.EnableEvents = False
Activeworkbook.close SaveChanges:=False ' or true Application.EnableEvents = True -- Regards, Tom Ogilvy "Wellie" wrote in message ... I added cVBA code in the "BeforeClose()" event to check to ensure user would enter mandatory data before existing. If they don't, I keep the excel open by using the "Cancel=true" command." I recently found out that users use the Windows Tasks Manager to terminate the Excel even they know that there are mandtory fields data required. Now, when I run codes data collection VBA codes in my "Master" spreadsheet to collect data from those returned spreadsheets, I ran into trouble. In my VBA code, after openning the workbook and found mandatory data is missing, I stop processing for the opened spreadsheet but I CANNOT open it because of the "BeforeClose()'s cancel=true" statement. Can someone please tell me how can I close this spreadsheet (one one with the Cancel=True statment) in my "Master" spreadsheet's VBA ? Here is log highlevel pseudo-code: MasterSpreadsheet { Open "DataSpreadsheet" Check for Mandatory data if ok then process data and close :) "DataSpreadsheet" else close "DataSpreadsheet" - NOW I cannot close it because I have a "Cancel=TRUE" statement inside which found that Mandatory data is missing. endif } -- Wellie ------------------------------------------------------------------------ Wellie's Profile: http://www.excelforum.com/member.php...o&userid=15370 View this thread: http://www.excelforum.com/showthread...hreadid=269874 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
Typing "true" excel 2007 change it to "TRUE" | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
What is "Cancel=True"? | Excel Programming | |||
File won't close when "beforeclose" event is used. | Excel Programming |