Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a workbook with a bunch of VB code in it.
I have this workbook and any other workbook open, but this workbook is not active. I click the X to shut down Excel. It calls the Workbook_BeforeClose event, then asks if I want to save my work (as it should). I select "Save All" and the shut down is aborted. It never makes it to the Workbook_BeforeSave event. I then click the X a second time, and I'm not prompted to save but the shut down proceeds with saving all and then closing Excel. == Why does it require a second click of the X? If this workbook is active, all works fine. I've commented out all event code. Didn't help. I've deleted my commandbar menu before attempting to close. Didn't help. The order in which the workbooks were opened doesn't matter. What might I be doing in VB to cause this behavior? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Add "Cancel = True" to your code.
-- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "Dean Meyer" wrote in message I have a workbook with a bunch of VB code in it. I have this workbook and any other workbook open, but this workbook is not active. I click the X to shut down Excel. It calls the Workbook_BeforeClose event, then asks if I want to save my work (as it should). I select "Save All" and the shut down is aborted. It never makes it to the Workbook_BeforeSave event. I then click the X a second time, and I'm not prompted to save but the shut down proceeds with saving all and then closing Excel. == Why does it require a second click of the X? If this workbook is active, all works fine. I've commented out all event code. Didn't help. I've deleted my commandbar menu before attempting to close. Didn't help. The order in which the workbooks were opened doesn't matter. What might I be doing in VB to cause this behavior? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for trying to help, Jim.
"Cancel" is not a defined parameter of Workbook_WindowDeactivate so I can't add it there. I loaded Excel fresh, started with a blank workbook and typed the following into the VB ThisWorkbook object: Sub Workbook_WindowDeactivate(ByVal Wn As Window) End Sub Then I opened any other Excel workbook, made some edit to force a save, and clicked the big red X. The problem occured! Jim Cone wrote: Add "Cancel = True" to your code. -- Jim Cone |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I never said it was.
The only events you mentioned in your original post were BeforeClose and BeforePrint. Jim Cone San Francisco, USA "Dean Meyer" wrote in message Thanks for trying to help, Jim. "Cancel" is not a defined parameter of Workbook_WindowDeactivate so I can't add it there. I loaded Excel fresh, started with a blank workbook and typed the following into the VB ThisWorkbook object: Sub Workbook_WindowDeactivate(ByVal Wn As Window) End Sub Then I opened any other Excel workbook, made some edit to force a save, and clicked the big red X. The problem occured! Jim Cone wrote: Add "Cancel = True" to your code. -- Jim Cone |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That should have read... were BeforeClose and BeforeSave.
Jim Cone "Jim Cone" wrote in message I never said it was. The only events you mentioned in your original post were BeforeClose and BeforePrint. Jim Cone San Francisco, USA |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jim, thanks again for trying to help.
You're absolutely correct; my first message was misleading. After more work, I was able to isolate the problem to the Workbook_WindowDeactivate or Workbook_Deactivate events. If you're still of a mood to help, have a look at my 3:46PM message above. Thanks again, --Dean |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Found a clue: The problem occurs if ThisWorkbook contains a
Workbook_WindowDeactivate or an Application_WindowDeactivate procedure, EVEN IF THERE'S NO CODE IN IT. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I loaded Excel fresh, started with a blank workbook and typed the
following into the VB ThisWorkbook object: Sub Workbook_WindowDeactivate(ByVal Wn As Window) End Sub Then I opened any other Excel workbook, made some edit to force a save, and clicked the big red X. The problem occured! Can anybody replicate? Any clues as to why or a work-around? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel takes forever to shut down | Excel Programming | |||
Ignoring code to shut a workbook if it is already shut | Excel Discussion (Misc queries) | |||
Shut down excel | Excel Discussion (Misc queries) | |||
optionbutton takes two clicks to change value | Excel Programming | |||
recvery msg and excel shut down | Excel Programming |