Application.Quit en Excel crash

J

Jos Vens

Hi,

My program starts with a Login-form, where the user has to give a password
to go inside the application. On that login-form, you have an OK-button,
and a Cancel button.

Pressing the cancel button closes the form and then quits excel with
application.quit.

Not always but often, excel crashes here, and I don't know why. In the
past, I got some reasons for a crash:

-not unloading the form and application.quit = crash
-not Office XP-SP3 = crash

So now, it works fine (I installed SP3 on Office XP). However, on another
machine with Office2000, it didn't crash until I installed SP3 of
Office2000.

What am I doing wrong, why is Excel crashing on Application.quit?

Thanks
Jos Vens
 
J

Jos Vens

Additional information:

I think the problem has something to do with a non-modal Login-form. When I
trace, I encounter the application.quit command, but Excel does not quit! It
runs still some code, which is not valid anymore (hidden workbooks are
closed)

Jos
 
J

Jos Vens

Hi,

I found the solution: when I set Application.EnableEvents=false, before
Application.Quit, there is no further code running and there is no crash,
not on Office XP nor on Office 2000. I still wonder why Excel continues
running code after Application.Quit??? As far as I remember, it worked fine
when my userform was modal.

Jos
 
J

Jim Thomlinson

Thanks for posting your solution... I have had the smae problem in a 2000
application. I neer worried about it becuase we are migrating to 2003 but if
the problem persists...
 
T

Tushar Mehta

Thanks for sharing the solution. It is *possible* that your code did
not crash with the userform showed modally because XL stops executing
the VBA code and stops the user from interacting with it while the
userform is visible. With a modeless form, all other activity proceeds
while the dialog box is visible. So, other macros including event
procedures will be executed *asynchronously* with the thread displaying
the userform.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top