Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Application.quit error

Hello

My code looks at a cell in my active workbook and if the value is zero, then quit. It works fine if I step through it using F8, but when the code runs through Workbook_Open, it will error out. When i hit debug, it just shuts down Excel. Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Application.quit error

"Sabosis" skrev i melding
...
Hello

My code looks at a cell in my active workbook and if the value is zero,
then quit. It works fine if I step through it using F8, but when the code
runs through Workbook_Open, it will error out. When i hit debug, it just
shuts down Excel. Any ideas?


Not knowing your code, code that runs fine in steps but not in sequence
usually needs DoEvents inserted here and there. The word means something
like "listen to the operating system, and also wait here until the last
instruction is completed"

This said, Application.Quit is very brutal. Excel allows us to have multiple
tasks and documents open simoultaneouslly. Very few, or in real life no,
documents have the right to do shut everything down.

HTH. Best wishes Harald


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Application.quit error

On 29/05/2013 19:08, Sabosis wrote:
Hello

My code looks at a cell in my active workbook and if the value is zero, then quit. It works fine if I step through it using F8, but when the code runs through Workbook_Open, it will error out. When i hit debug, it just shuts down Excel. Any ideas?


I am not too surprised. A workbook whose own Workbook_Open action shuts
down Excel so brutally is likely to get itself into trouble by removing
services that it is still intending to use.

If it works OK in Debug but not in real life then there is some kind of
race condition between your application code and the Windows OS. These
can usually be fixed with a liberal application of DoEvents.

However, you should probably rethink your logic since users will not
thank you if Excel shuts down on them spontaneously whilst opening your
workbook and as a result junks all their unsaved work!

--
Regards,
Martin Brown
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Application.quit error

Hello

My code looks at a cell in my active workbook and if the value is
zero, then quit. It works fine if I step through it using F8, but
when the code runs through Workbook_Open, it will error out. When i
hit debug, it just shuts down Excel. Any ideas?


Very bad practice!!!
*NEVER, NEVER, NEVER* write code that shuts down a non-automated
instance of Excel (or any other MS Office app)!!!

If startup conditions do not meet your criteria then just close your
workbook!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
difference application.quit & application.close Pierre via OfficeKB.com[_2_] Excel Programming 4 November 8th 05 07:55 PM
macro to close excel application other than application.quit mary Excel Programming 1 September 14th 04 03:43 PM


All times are GMT +1. The time now is 07:50 PM.

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"