Article ID: 193245
Article Last Modified on 6/17/2005
Sub Auto_Open()
' This sub will close all workbooks
' except the workbook in which the code is located.
Dim WkbkName As Object
On Error GoTo Close_Error
Application.ScreenUpdating = False
For Each WkbkName In Application.Workbooks()
If WkbkName.Name <> ThisWorkbook.Name Then WkbkName.Close
Next
Application.ScreenUpdating = True
' If everything runs all right, exit the sub.
Exit Sub
' Error handler.
Close_Error:
MsgBox Str(Err) & " " & Error()
Resume Next
End Sub
Additional query words: XL98
Keywords: kbhowto kbdtacode KB193245