I have 6 files that execute macros each after another. The 1st file with VBA code (master file) opens remaining 5 files and initiates VBA chain reaction. The 2nd file does the macro job and initiates job of the 3rd file and it goes until 6th file.
The 6th file then refers to the 1st file's macro (master), which is supposed to close all 5 workbooks (apart from this 1stone). The code of 6th workbook looks like this:
Application.DisplayAlerts = False
ThisWorkbook.RefreshAll
Workbooks("6th_file.xlsm").SaveAs Filename:= _
"[URL]6th_file_htm.htm"
Application.Run ("refresh_tool.xlsm!CloseAll.CloseAll")
Then it goes to:
Option Explicit
Sub CloseAll()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim wb3 As Workbook
Dim wb4 As Workbook
Dim wb5 As Workbook
Set wb1 = Workbooks("wb1.xlsm")
Set wb2 = Workbooks("wb2.xlsm")
Set wb3 = Workbooks("wb3.xlsm")
Set wb4 = Workbooks("wb4.xlsm")
Set wb5 = Workbooks("wb5.xlsm")
wb1.Close
wb2.Close
wb3.Close
wb4.Close
wb5.Close
The result is that when run in that chain only the first workbook is closed (refresh_tool, wb2, wb3, wb4 and wb5 remain open).
However, when the CloseAll() is run alone - it works properly and closes all 5 files (only refresh_tool remains open).
I tried make it simple at first with Workbooks("...").Close, but tried several things already, ending up with the code above.
Can anyone help please?