Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default It takes two clicks to shut down Excel

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default It takes two clicks to shut down Excel

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default It takes two clicks to shut down Excel

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default It takes two clicks to shut down Excel

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default It takes two clicks to shut down Excel

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default It takes two clicks to shut down Excel

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default It takes two clicks to shut down Excel

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default It takes two clicks to shut down Excel

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
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
Excel takes forever to shut down Albert Excel Programming 2 December 1st 06 03:45 PM
Ignoring code to shut a workbook if it is already shut Cammy Excel Discussion (Misc queries) 1 September 12th 06 06:12 PM
Shut down excel Greg B Excel Discussion (Misc queries) 1 April 26th 05 07:05 AM
optionbutton takes two clicks to change value Will Gardner Excel Programming 2 December 1st 04 03:00 PM
recvery msg and excel shut down helmekki[_21_] Excel Programming 1 September 30th 04 02:25 AM


All times are GMT +1. The time now is 04:14 AM.

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

About Us

"It's about Microsoft Excel"