Hello,
I have some code, App A, in WBook A that opens WBook B, loads data and then closes WBook A...it works great. Now enter WBook C which can open WBook A and run App A. I end up with WBook B open, as I wish, but ThisWorkbook.Close fails. I have put this line in AppC right after the Call App A instruction but it leaves WBook C open. I have also tried putting Close C into App A but then it leaves WBook A open.
Book C calls Book A
This closes C but leaves A open
Alternatively, I have tried closing Book C from the code in App C
Any suggestions would be greatly appreciated!
David
I have some code, App A, in WBook A that opens WBook B, loads data and then closes WBook A...it works great. Now enter WBook C which can open WBook A and run App A. I end up with WBook B open, as I wish, but ThisWorkbook.Close fails. I have put this line in AppC right after the Call App A instruction but it leaves WBook C open. I have also tried putting Close C into App A but then it leaves WBook A open.
Book C calls Book A
Code:
Public Sub Open_A
...various
Application.Run "BookA.xls!Load_BookB"
End Sub
Code:
Public Sub Load_BookB
'...various opening of B and loading data...works great
Application.ScreenUpdating = True ' Book B appears on Screen
Application.ScreenUpdating = False
Call Close_Book_C
Application.ScreenUpdating = True
ThisWorkbook.Close SaveChanges:=False ' this fails
End Sub
Alternatively, I have tried closing Book C from the code in App C
Code:
Public Sub Open_A
...various
Application.Run "BookA.xls!Load_BookB"
'includes ThisWorkbook.Close, which does work to close A
ThisWorkbook.Close SaveChanges:=True 'this fails
End Sub
David