View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Wellie[_3_] Wellie[_3_] is offline
external usenet poster
 
Posts: 1
Default 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