Article ID: 147742
Article Last Modified on 10/11/2006
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
' If everything runs all right, exit the sub.
Exit Sub
' Error handler.
Close_Error:
MsgBox Str(Err) & " " & Error()
Resume Next
End Sub
163435 VBA: Programming Resources for Visual Basic for Applications
226118 OFF2000: Programming Resources for Visual Basic for Applications
Additional query words: 5.00a 5.00c 8.00 XL97 XL7 XL5
Keywords: kbdtacode kbhowto kbprogramming KB147742