first time class module
Bob Phillips wrote:
I haven't seen this on Walkenbach, but this doesn't seem right.
I am assuming that the ABuse commandbar applies to a single workbook? If so,
why are you using application events which would apply to all workbooks? And
as it applies to all workbooks, why would you want to hide it when any, or
all, workbooks close.
Thanks for pointing that out. I got confused between "Application"
level and "Document" level. I went back and re-read Walkenbach, and it
says "Application", which is what I thought I wanted. I guess when it's
only a particular workbook, it's document level. I was thinking that a
worksheet would be document level, and a workbook would be application
level.
I would have thought that you should have some code to build or make visible
the Abuse commandbar, and some code to hide it. If it applies to a single
workbook, the best places would be the workbook open and beforeclose
events.
I already have the code to show the toolbar when I select the
appropriate sheet and hide the toolbar when I move to another sheet,
and it works great. Now I'm trying to close all the custom toolbars,
not the Standard or Formatting toolbars, when I close the workbook.
--
HTH
RP
"davegb" wrote in message
oups.com...
I want to hide a toolbar called "Abuse" when the workbook closes. I
looked it up in Walkenbach and tried to modify the code I found there
for my purpose. It doesn't work, but it doesn't hang either. Surprising
that it doesn't hang up.
Here is the code from the Class Module "HideToolbar"
Public WithEvents AppEvents As Application
Private Sub appevents_beforeclose()
Application.CommandBars("Abuse").Visible = False
End Sub
Here is the code from "ThisWorkbook":
Private Sub BeforeClose()
Call Init
End Sub
Here's the code from the regular module:
Dim AppObject As New HideToolbar
Sub Init()
Set AppObject.AppEvents = Application
End Sub
Any ideas on why it doesn't hide the toolbar?
Thanks in advance.
|