View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Corey Corey is offline
external usenet poster
 
Posts: 363
Default Excel 2007 Craches when closing via macro code

When i close a workbook through code such as :

sub button6()
Application.DisplayAlerts = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

and

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Dim WB As Workbook
For Each WB In Application.Workbooks
Debug.Print WB.Name
If WB.Name < ThisWorkbook.Name Then
If WB.Windows(1).Visible = True Then Exit Sub
End If
Next
Sheets("Navigation Sheet").Select
Application.Quit
End Sub


I get an ERROR, prompts me to \send report to MS or not.

If i open Excel and a blank sheet and then exit excel i get No error, so it seem to be ONLY when
exiting via code.

How do i fix this?


Corey....