VB 6 COM Add-in for Outlook 2007

G

goran

Hi All,

I have a working Outlook 2003 COM add-in written in VB 6.0 based on Ken's
ItemsCB template with Inspector wrapper class. It adds custom toolbar with
few buttons and dropdown on the Inspector window. It works in Outlook 2007,
but it is located under 'Add-ins' tab. What should I change so it will show
up on the 'Message' tab instead, and use existing code in button_click event.
Also what would be the easiest way to convert this to VSTO add-in for
Outlook 2007 so I don't have to change much.

Thanks,

Goran
 
K

Ken Slovak - [MVP - Outlook]

That's where the sneaky part comes in :)

In cases like that I put a public property in my Inspector wrapper class
called Ribbon that is set to the Ribbon object in my Connect class (or you
can make the Ribbon object in Connect global). I also put in the wrapper
class a public Sub that I usually call RibbonClicker().

I also have a public Inspector property in the wrapper class that returns
the Inspector for that class.

In Outlook 2007 you can directly compare control.Context from the ribbon
callback to the Inspector property in each existing wrapper class instance
using equality:

If (control.Context = wrapper(i).Inspector) Then

So I always can get the correct Inspector wrapper class.

I then call into the wrapper class's RibbonClicker() procedure, passing
along the ribbon control.ID as an argument to RibbonClicker().

In RibbonClicker() I compare the id (ribbon control tag) to the tags for all
the available ribbon controls and from that I know which control was clicked
and which button event handler it corresponds to. I then set up a dummy null
CommandBarButton and a dummy boolean Cancel variable and pass those to the
appropriate button click event handler, which then executes the code for
that event handler.

In cases where I need to pass other information to the eventual procedure to
handle the clicks I have both the button event handler and the ribbon
clicker procedure call the same child procedure to execute the click code.
 
G

goran

Thanks a lot as always Ken.

This thing worked, and I am able to route callbacks to my specific Wrapper
code. But now I am confused. I used to have dropdown control in inspector
wrapper that I declared as:
Private WithEvents CBInspectorDropdown As Office.CommandBarComboBox,

and then I pull the items from DB and populated this dropdown when Inspector
opened. I also had _Change event for the dropdown where I would put the code
to do something based on user selection. Now, I defined dropdown in xml. How
can i reference that dropdown in my code in vb 6 and load with items in the
runtime, get selected item etc.

thanks,

Goran
 
K

Ken Slovak - [MVP - Outlook]

The ribbon combo is populated by XML when the control is initialized,
therefore it's not so great for dynamically populated lists. About the only
way I've found to do that is to actually create the ribbon XML on the fly
when GetCustomUI fires.

For dynamically populated controls I usually prefer to use the dynamicMenu
control, which has a getContent callback that's used to provide the XML for
the control. You still have to create that XML on the fly but you don't have
to create the entire ribbon XML on the fly. Of course the dynamicMenu
control doesn't have that textbox associated with it.

For combo's you get an onChange callback.

You might find the articles starting at
http://msdn2.microsoft.com/en-us/library/aa338202.aspx to be of interest.
The code samples are in C# and VB.NET, but they're simple and readable.
 
G

goran

Thanks Ken. And where should I check this if
(control.context=wrapper(i).inspector?

In the connection module or in inspector wrapper class?
 
G

goran

I can create xml dynamically. But how can I reference combobox in the code
once it is populated? For example, when I click on the button next to
combobox I want to get the currently selected index and selected text. Do I
refer to it by id that I specified in the xml?

Thanks,

Goran
 
K

Ken Slovak - [MVP - Outlook]

Unfortunately that's not exposed.

Dennis's tlb doesn't expose some ribbon-related methods in the Office 12
library such as ExecuteMso(idMSO) or GetEnabledMso(idMSO), but there isn't a
method for reading either of those combo properties.

You have to track the state of any property you want to evaluate yourself.
When the combo's onChange() callback fires you would update your property
variables. The second of those articles I referenced has a complete list of
all combo callbacks.
 
G

goran

And if I want to use Office 12 library and I have Outlook 2007 installed, are
there ways to get currently selected dropdown text and index like it used in
Office 11?
 
K

Ken Slovak - [MVP - Outlook]

There isn't a method for reading either of those combo properties, no matter
what reference or library you use. The ribbon designers didn't think we'd
need things like that.
 
G

goran

Thanks.

Ken Slovak - said:
There isn't a method for reading either of those combo properties, no matter
what reference or library you use. The ribbon designers didn't think we'd
need things like that.
 
R

Rob Holmes

Hi Ken,

Could you tell me where I can get hold of the XLIRibbonExtensibility tlb? -
I can't find it anywhere :(

Many thanks,

Rob Holmes.
podia.
 

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