automatically show/hide toolbar

  • Thread starter Thread starter Peter T
  • Start date Start date
P

Peter T

Hi,

A 3rd party AV app has created a toolbar that displays permanently. But it's
only useful in Mail view

Is it possible to make it visible when mail view is activated and not
visible in all other views (say when mail view is de-activated or any other
view activated),

TIA,
Peter T
 
What version of Outlook?

You can get the CommandBars collection for the ActiveExplorer object and
iterate that collection looking for the toolbar by name. Then you can use
the Visible property of the CommandBar object to set visibility to true or
false based on the ActiveExplorer.CurrentFolder.DefaultItemType property.
For mail items that property would be olMailItem.
 
Hi Ken,

Outlook 2003 (sorry I should have said)

I've got this far

Dim cb As CommandBar
Set cb = Application.ActiveExplorer.CommandBars("ESET Smart Security")

Does changing the current folder trigger some event in which the visible
property of the commandbar can be changed, or is there some other way to do
it.

Regards,
Peter T
 
To detect when a folder is switched in the Explorer you'd use the
Explorer.BeforeFolderSwitch() event. That passes you NewFolder As Object,
where NewFolder is the folder being switched to.
 
OK I think I've got it (this is 1st time I've ever opened Outlook's VBE)


' ThisOutlookSession

Dim c As clsExplorer

Private Sub Application_Startup()
Set c = New clsExplorer
Set c.exp = Application.ActiveExplorer

End Sub


' code in clsExplorer

Public WithEvents exp As Explorer

Private Sub exp_BeforeFolderSwitch(ByVal NewFolder As Object, Cancel As
Boolean)
Dim bVis As Boolean
Dim cb As CommandBar

On Error GoTo errH
Set cb = Application.ActiveExplorer.CommandBars("ESET Smart Security")
bVis = NewFolder.DefaultItemType = olMailItem
cb.Visible = bVis
errH:
End Sub


Just curiosity, how do other toolbars toggle visibility depending on the
current view. IOW wondering if perhaps there is some way of associating a
custom toolbar with a particular view and avoiding VBA.

Thanks again,
Peter T
 
Other custom toolbars do exactly what you're doing, except they usually do
it in a COM addin and not the Outlook VBA project. Outlook does the same
thing, but it uses Extended MAPI code in C++ instead of using the Outlook
and Office object models.

Good job on a first effort.
 
Yes a Com-Addin is better. Also allows macro security HIGH. With the VBA
version had to set it to medium even with a "SelfCert" added.

If anyone wants this VB6 CAI (Outlook 2003 only) for the particular toolbar
I mentioned, my address is disguised in the reply-to.

Indeed this is my "first effort" with Outlook though not my first attempt at
VB/A :-)

Thanks again for your help,
Peter T
 
Using a self-cert signature will let you use high security if you trust that
certificate. You can use IE options, Content tab to add the signature to
your certificate store and trust it.
 
Yes you're right, I must have missed something somehow.

I never needed to manually add the (selfcert) certificate in IE
Options/Content but it's there.

On reflection I'll dispense with the ComAddin, VBA works just as well and
easier to tweak!

Regards,
Peter T
 
Back
Top