i'm stuck with an excel qujitting problem

E

E.Anderegg

Hello
I have a Worksheets with several vba macros. When a user opens it, it
displays only a dialog (sort of welcome disclaimer), and when the user
clicks ok, the rest of the worksheets are made visible.
This works .
Tomake sure that a startup no other ecxel windows are displayed, I created a
before_Close routine, which hides all open windows of the workbook and then
saves it.

Closing the workbook works fine.
Quitting excel hides and saves the workbook, but does not close Excel!!!
I have to quit excel a second time, which then works.
What's wrong ??
Any help is appreciated

Ernst


Code at startup:

Private Sub Workbook_Open()
Frm_Intro.Show
ThisWorkbook.Windows(1).Visible = True
ThisWorkbook.Worksheets("Input").Visible = True
etc

at close:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
For Each Window In ThisWorkbook.Windows
Window.Visible = False
Next
ThisWorkbook.Save
 
T

Tim

Ernst,

Thisworkbook.close is not the correct method for "closing"
Excel. You should be using "application.quit"

-Tim
 

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