.Net, C#, msoControlComboBox, msoControlEdit, Outlook, Outlook 2007, Outlook 2010, Programming, Software, VB.NET, VSTO

VSTO for MS Outlook 2007 – Using msocontroledit and msoControlComboBox in the Commandbars

Outlook Custom Search Fields
Outlook Custom Search Fields

VSTO for MS Outlook can be a powerful way to customize Outlook programmatically. However, the syntax can be finicky at times and I have found a few instances where the programming logic becomes tricky.

For example, you can use VSTO to add a text box to the Outlook command bar window. This can be put to a number of good uses when building a custom component for Outlook. My thoughts behind adding the controls to Outlook were to allow the user to select a type of search to run in the custom dropdown list, and then to use the text box for the user to add text that the system would use to run a search on custom email fields.

In my case I wanted to add a textbox and a ComboBox to my main Outlook Explorer view. The VSTO controls in Outlook are called msoControlEdit and msoControlComboBox respectively.

At first glance adding a simple text box and dropdown list sounds like a simple requirement. But as I found out, this isn’t quite the case. The problem? Outlook by default will clear any entered text from the new text box when focus is lost. I’m not sure what the reasoning behind this is, but from reading help articles  and forum posts, it appears that many people are coming up against the same problem.

As a positive, the ComboBox control does retain selected text, so we will not need to worry about handling this control.

For the convenience of readers of this article; I am including a full example of how to add a textbox and a ComboBox  to the Outlook main command bar at the end of this article.

Continue reading “VSTO for MS Outlook 2007 – Using msocontroledit and msoControlComboBox in the Commandbars”

Advertisement