Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Typing "true" excel 2007 change it to "TRUE" Mr. T Excel Discussion (Misc queries) 2 April 11th 07 01:24 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
What is "Cancel=True"? universal[_23_] Excel Programming 3 January 13th 04 04:27 PM
File won't close when "beforeclose" event is used. David G[_3_] Excel Programming 4 December 8th 03 04:22 AM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"