M
Mark
Hi,
I’m trying to “fully†close a workbook via VBA in XL 2007 and having some
problems with it. Specifically, the Project window in the VBE still shows the
workbook. What I’m doing is creating a workbook based on a template and when
the User is done they simply “X†out of it and all of it works correctly,
except for what remains in the VBE. I can re-open and manipulate the workbook
created from the template, but the VBE still shows it. The code for the
template (ThisWorkbook) is:
Sub Workbook_BeforeClose(Cancel As Boolean)
Run "Personal.xls!EndIt", Cancel
End Sub
The Personal.xls code, in a standard module, is:
Sub EndIt(Cancel As Boolean)
ChDir extPath & grade
ActiveWorkbook.SaveAs extPath & grade & "\" & fName, FileFormat:=52
ActiveWorkbook.Close
Application.Caption = Empty
End Sub
At the time the code reaches the BeforeClose event, the following
conditions of the workbook are:
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
There are no additional add-ins and it doesn’t seem to cause any problems,
however, from time to time, Excel does abend and wants me to send an error
report. Does anyone know why the workbook I create from the template appears
to close correctly in Excel, but not in the VBE Project window and what I
have to do to fix it?
Thanks.
Mark
I’m trying to “fully†close a workbook via VBA in XL 2007 and having some
problems with it. Specifically, the Project window in the VBE still shows the
workbook. What I’m doing is creating a workbook based on a template and when
the User is done they simply “X†out of it and all of it works correctly,
except for what remains in the VBE. I can re-open and manipulate the workbook
created from the template, but the VBE still shows it. The code for the
template (ThisWorkbook) is:
Sub Workbook_BeforeClose(Cancel As Boolean)
Run "Personal.xls!EndIt", Cancel
End Sub
The Personal.xls code, in a standard module, is:
Sub EndIt(Cancel As Boolean)
ChDir extPath & grade
ActiveWorkbook.SaveAs extPath & grade & "\" & fName, FileFormat:=52
ActiveWorkbook.Close
Application.Caption = Empty
End Sub
At the time the code reaches the BeforeClose event, the following
conditions of the workbook are:
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
There are no additional add-ins and it doesn’t seem to cause any problems,
however, from time to time, Excel does abend and wants me to send an error
report. Does anyone know why the workbook I create from the template appears
to close correctly in Excel, but not in the VBE Project window and what I
have to do to fix it?
Thanks.
Mark