View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Aaron Queenan Aaron Queenan is offline
external usenet poster
 
Posts: 30
Default Disable Button when no workbooks are open.

I've tested in XL 2000 and XL 2002, using a C++ COM add-in. I've tested in
XL 2002 using your VBA code. The Workbook_BeforeClose event handler is
always called _before_ the dialogue box asking the user to save. Therefore
the icon would be disabled before the user pressed the cancel button.

Even if the BeforeClose event came after the dialogue box, there would still
be another bug waiting to rear it's head. Consider the following scenario:

- A user has two add-ins installed on the computer, both which monitor the
BeforeClose event in the same way.
- One add-in sometimes sets the Cancel flag. The other add-in uses your
code.
- If the BeforeClose event is called in the other add-in first, there is no
problem.
- If the BeforeClose event is called in your add-in first, if the other
add-in sets the Cancel flag you will have already disabled the icon.

Regards,
Aaron Queenan.

"JE McGimpsey" wrote in message
...
Aaron-

Did you try my solution before you posted? If so, what version of XL?

For me (XL98, XL01, XLv.X, XL03), the icon is *not* disabled before the
user is asked to save, and if the user cancels, the control is still
enabled.



In article ,
"Aaron Queenan" wrote:

Try this with JE's code: Edit a workbook, click the close icon. You're
icon will disable. Click cancel. Your icon will be disabled even

though
there is still a workbook open.