New Toolbar

M

m stroup

I have code attached to a button on a new toolbar. I added the toolbar to
the new appointment form which is correct. But now I see the toolbar on the
new email, new task etc. forms. It is only appropriate on the new
appointment form.

Any suggestions?
 
M

m stroup

I figured it out. I just removed it from all forms and reset it on the
appointment form.
 
M

m stroup

So, that really didn't fix it.

I created a toolbar called "myOLAddOns". I want it to only be
enabled/visible/present on the new appointment form. I am new to outlook
programming (as you will see) but this is what I have so far and it is not
working. Any suggestions would be greatly appreciated.

I have added this code to "this outlook session", thinking it would be
triggered anytime I opened a "new" form.

Dim objApp As Application
Dim objIns As Outlook.Inspector
Dim objItem As Object
Dim objCB As Office.commandbars
Dim objCBB As CommandBarControl


Set objApp = CreateObject("Outlook.Application")
Set objIns = objApp.ActiveInspector
Set objItem = objApp.ActiveInspector.CurrentItem
Set objCB = objIns.commandbars
Set objCBB = objCB.item("myOlAddOns").Controls.item("Post to Personal
and Team Lead Calendars")
If objIns.Class = olAppointment Then
objCBB.Enabled = True
Else
objCBB.Enabled = False
End If
 
G

Guest

You need to monitor the NewInspector event for a Inspectors collection
declared using WithEvents at the module level. You would get the Inspectors
collection from the Application.Inspectors object during Application_Startup
in ThisOutlookSession. Then simply don't process any Inspectors in the
NewInspector event if it doesn't meet your criteria.

It's also best to implement an Inspector wrapper, so that your custom
toolbars/buttons will work if multiple items are opened (and you won't be
subject to the "last inspector wins" scenario).

For some great sample code that shows best practices with Inspectors and
custom toolbars, see the COM Add-In projects here:
http://www.slovaktech.com/code_samples.htm

--
Eric Legault [MVP - Outlook]
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, MOSS 2007
& WSS 3.0 Application Development)
Collaborative Innovations
-> Try Picture Attachments Wizard For Microsoft Outlook <-
Web: http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top