View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Application.quit

You code would close the workbook with the code which causes the code to
terminate at that point.

Just do

for each bk in Application.Workbooks
bk.Save
Next
Application.Quit


"yuiriy" wrote in message
...
Why this code don't close excel? Code is assigned to button into userform

Private Sub CommandButton4_Click()
ActiveWorkbook.Save
If Workbooks.Count 1 Then
ActiveWorkbook.Close
Else
Application.Quit
End If
End Sub

TIA