D
Dave Unger
Hello everyone,
I placed this post a few days ago, but my question remains
unaswered. This is a re-word of that post.
I have a large application that “hides” Excel on startup (gridlines,
headings, visibility, etc), then restores everything on exit.
Everything works fine if closing the workbook manually, the problem
appears when trying to close via a procedure. The following is a
simplified example of the code.
Sub CloseMe()
ThisWorkbook.Close savechanges:=True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim wk As
Worksheet
Range("A1").Interior.ColorIndex = 4
Application.DisplayFormulaBar = True
ActiveWindow.DisplayGridlines = True
End Sub
If I step thru the code starting at CloseMe code, it steps thru to the
Workbook_BeforeClose procedure. There, the first line gets executed,
but nothing happens on the next two. Yet when I close the workbook
manually, it works as expected. I’ve tried this on Xl97 & 2007, with
the same results.
I have to admit, this one caught me by surprise. I can’t seem to find
anything regarding this in the groups/internet. Any advice would be
most appreciated.
Thanks for your help,
regards,
Dave U
I placed this post a few days ago, but my question remains
unaswered. This is a re-word of that post.
I have a large application that “hides” Excel on startup (gridlines,
headings, visibility, etc), then restores everything on exit.
Everything works fine if closing the workbook manually, the problem
appears when trying to close via a procedure. The following is a
simplified example of the code.
Sub CloseMe()
ThisWorkbook.Close savechanges:=True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim wk As
Worksheet
Range("A1").Interior.ColorIndex = 4
Application.DisplayFormulaBar = True
ActiveWindow.DisplayGridlines = True
End Sub
If I step thru the code starting at CloseMe code, it steps thru to the
Workbook_BeforeClose procedure. There, the first line gets executed,
but nothing happens on the next two. Yet when I close the workbook
manually, it works as expected. I’ve tried this on Xl97 & 2007, with
the same results.
I have to admit, this one caught me by surprise. I can’t seem to find
anything regarding this in the groups/internet. Any advice would be
most appreciated.
Thanks for your help,
regards,
Dave U