i'm stuck with an excel qujitting problem

  • Thread starter Thread starter E.Anderegg
  • Start date Start date
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
 
Ernst,

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

-Tim
 
Back
Top