Having trouble closing Excel from macro...need help.
Posted by Ed Cupstid on January 19, 2002 2:27 PM
I have a batch file that starts up an Excel workbook and automatically runs a macro using auto_open, after the macro finishes it's task and saves the workbook I need the workbook to close and Excel to shutdown. Everything is working great, the workbook is saved and closes, but I can not get Excel window to close and shutdown. I am using the following code to close Excel, but it doesn't work, any help would be appreciated:
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
Dim Wb As Workbook
For Each Wb In Workbooks
If Wb.Name <> ThisWorkbook.Name Then
Wb.Close savechanges:=True
End If
Next Wb
Auto_Close
End Sub
Sub Auto_Close()
ThisWorkbook.Close savechanges:=True
End Sub