Option Explicit
Sub Workbook_Open()
Application.ScreenUpdating = False
Application.EnableEvents = False
Workbooks.Open (ThisWorkbook.Path & "\Book2.xlsm")
Application.EnableEvents = True
ThisWorkbook.Windows(1).Activate
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim WB As Workbook
Application.ScreenUpdating = False
Application.EnableEvents = False
'Loop through each workbook
For Each WB In Application.Workbooks
'Close the workbooks and save changes.
If WB.Name <> ThisWorkbook.Name Then
WB.Saved = True
WB.Close SaveChanges:=False
DoEvents
End If
Next WB
Application.EnableEvents = True
Application.ScreenUpdating = True
ThisWorkbook.Saved = True
Application.Quit
End Sub