View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default How to make Excel 2007 quit automatically

You can try this to close and save the workbook and
if it is the only file that is open close Excel

Dim wb As Workbook
Dim I As Integer

For Each wb In Application.Workbooks
If wb.Windows(1).Visible Then I = I + 1
Next wb
If I = 1 Then
Application.Quit
ThisWorkbook.Close SaveChanges:=True
Else
ThisWorkbook.Close SaveChanges:=True
End If

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Andrew Bourke" wrote in message ...
Hi
This

If Workbooks.Count < 1 Then Application.Quit


works in Excel 2003 but Excel 2007 tries to restart.
Is there something else I should try ?


TIA

Andrew