Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Cannot get Excel to Quit correctly

The aim is to add a blank wsheet prior to closing a wbook and format it for a
splashscreen whenever the wbook is reopened. The code works ok as far as
adding the blank wsheet but there are now problems with quitting Excel.

When trying to quit the application with the wbook open, the code saves the
wbook as required but does not quit the application without a second click.

Quitting the application only works as expected if the wbook is closed
first. Putting Application.Quit into the BeforeClose event will of course
quit Excel but this isn't always ideal.

Can anyone suggest a remedy please?

In ThisWorkbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets.Add After:=Sheets(Sheets.Count)

Sheets(Sheets.Count).Range("A100").Select 'prepare 'blank' sheet
ActiveWindow.DisplayGridlines = False
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayOutline = False
ActiveWindow.DisplayZeros = False
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayVerticalScrollBar = False
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1

Application.DisplayAlerts = False
ActiveWorkbook.Close savechanges:=True
Application.DisplayAlerts = True

End Sub

T.I.A.

Geoff

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Cannot get Excel to Quit correctly

I haven't run your code but this:

ActiveWorkbook.Close

within the close event itself looks problematic. How about just saving the
workbook and letting the close you're already in do its job?

--
Jim
"Geoff" wrote in message
...
The aim is to add a blank wsheet prior to closing a wbook and format it
for a
splashscreen whenever the wbook is reopened. The code works ok as far as
adding the blank wsheet but there are now problems with quitting Excel.

When trying to quit the application with the wbook open, the code saves
the
wbook as required but does not quit the application without a second
click.

Quitting the application only works as expected if the wbook is closed
first. Putting Application.Quit into the BeforeClose event will of course
quit Excel but this isn't always ideal.

Can anyone suggest a remedy please?

In ThisWorkbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets.Add After:=Sheets(Sheets.Count)

Sheets(Sheets.Count).Range("A100").Select 'prepare 'blank' sheet
ActiveWindow.DisplayGridlines = False
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayOutline = False
ActiveWindow.DisplayZeros = False
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayVerticalScrollBar = False
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1

Application.DisplayAlerts = False
ActiveWorkbook.Close savechanges:=True
Application.DisplayAlerts = True

End Sub

T.I.A.

Geoff



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Cannot get Excel to Quit correctly

Hi Jim
Just ActiveWorkbook.Save seems to suit requirements very well.

Many thanks for that.

Geoff



"Jim Rech" wrote:

I haven't run your code but this:

ActiveWorkbook.Close

within the close event itself looks problematic. How about just saving the
workbook and letting the close you're already in do its job?

--
Jim
"Geoff" wrote in message
...
The aim is to add a blank wsheet prior to closing a wbook and format it
for a
splashscreen whenever the wbook is reopened. The code works ok as far as
adding the blank wsheet but there are now problems with quitting Excel.

When trying to quit the application with the wbook open, the code saves
the
wbook as required but does not quit the application without a second
click.

Quitting the application only works as expected if the wbook is closed
first. Putting Application.Quit into the BeforeClose event will of course
quit Excel but this isn't always ideal.

Can anyone suggest a remedy please?

In ThisWorkbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets.Add After:=Sheets(Sheets.Count)

Sheets(Sheets.Count).Range("A100").Select 'prepare 'blank' sheet
ActiveWindow.DisplayGridlines = False
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayOutline = False
ActiveWindow.DisplayZeros = False
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayVerticalScrollBar = False
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1

Application.DisplayAlerts = False
ActiveWorkbook.Close savechanges:=True
Application.DisplayAlerts = True

End Sub

T.I.A.

Geoff




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 won't quit JRS Excel Discussion (Misc queries) 1 September 27th 05 04:31 AM
vba advice how 2get a input box to quit by entering the word quit+ 4 a msgbox to disp RELWOD85[_4_] Excel Programming 3 August 1st 05 07:11 PM
Excel Won't Quit Rex Excel Programming 13 May 11th 05 01:51 PM
Excel doesn't quit Jos Vens Excel Programming 2 February 27th 04 01:08 AM
Excel won't quit Jeff[_23_] Excel Programming 0 October 24th 03 05:14 PM


All times are GMT +1. The time now is 10:33 AM.

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

About Us

"It's about Microsoft Excel"