Quote:
I offered a solution to what I thought might help with your issue.
Since that's "obviously" what you did not want, why don't you post the code that you have.
It might be easier to figure out what you want from there.
Smitty
|
I'm sorry, Smitty. I do appreciate your trying to help, really. However, it looked like your code would just try to close every workbook that was open, except itself (the active one). It did not seem to correspond to the problem I described. It didn't seem to show me a way to close the workbook I was trying to close.
Here is the code I'm trying to execute. It is in the "ThisWorkbook" code module (i.e., an Excel object, not a macro module):
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbooks("Material Item List.xls").Close
End Sub
"Material Item List.xls" is a workbook that holds the material items list itself, some supporting code to maintain the list and, most importantly, code, forms and work tables (sheets) to display a pick list and return selected materials items to the calling application. Since I need this service for more than one applet, I have broken it out into its own workbook that can be shared by any applications that need it.
The user should normally not have to see the "Material Item List.xls" workbook, except when maintaining the list. That's why I would like it to automatically close when the calling application closes, just as it automatically opens when the calling application opens. However, Excel won't let that happen ... it puts up the error message I described in my first post (something like "... the referenced workbook cannot be closed because it is referenced by an open application.")
I hope you can help me figure out how to get around this obstacle. Thanks again (and sorry if I phrased my previous response badly).
