Customizing Microsoft Office commandbars
with custom controls in VB.NET, C#, C++

Toolbar Controls
for Microsoft Office


Add-in Express Home > Toolbar Controls for Office > Online Guide > Insight of Toolbar Controls

Insight of creating MS Office toolbar controls

Creating advanced Office toolbar controls - Video At first glance, the Toolbar Controls for Microsoft Office seems very easy-to-use, which is basically true. But all Office applications have unique features or troubles if using non-Office controls on their command bars. Let's see how the Toolbar Controls copes with this. Before we start, you may want to have a look at a sample project that shows how to customize Outlook toolbar with .NET controls.

ADXCommandBarAdvancedControl

The Toolbar Controls implements the ADXCommandBarAdvancedControl class. In addition to properties common for all command bar controls, ADXCommandBarAdvancedControl provides two special properties related to the Toolbar Controls.

The Control property

The Control property binds its ADXCommandBarAdvancedControl to a non-Office control and can be used at design-time as well as at run-time. To place your non-Office control on your command bar you just select your control in the Control property at design-time, or set the Control property to an instance of your control at run-time:

VB.NET


Private Sub AddinModule_AddinInitialize(ByVal sender As System.Object, _
	ByVal e As System.EventArgs) Handles MyBase.AddinInitialize
	
	BossCheckbox = New System.Windows.Forms.CheckBox
	Me.AdxCommandBarAdvancedControl1.Control = BossCheckbox
End Sub 

The ActiveInstance property

The ActiveInstance property is read-only and returns the instance of the Control that was created for the current context. For example, you can initialize your control for the active Inspector by handling the InspectorActivate event:

VB.NET



Private Sub adxOutlookEvents_InspectorActivate(ByVal sender As System.Object, _
	ByVal inspector As System.Object, ByVal folderName As System.String) _
	Handles adxOutlookEvents.InspectorActivate
	
	Dim ChkBox As System.Windows.Forms.CheckBox = _
                           Me.AdxCommandBarAdvancedControl1.ActiveInstance
	If Not IsNothing(ChkBox) Then ChkBox.Enabled = False
End Sub 

Please note, the ActiveInstance property is not actual in most cases when you'd like to use it. You can always use any window activate events such as the InspectorActivate event of Outlook and WindowActivate event of Word. The table bellow shows you the order of event processing by the example of the Outlook Inspector window opened by the user.

1. Outlook fires the built-in NewInspector event. Add-in Express traps it and fires the NewInspector event of ADXOutlookEvents.

ActiveInstance returns NULL.

2. ADXOutlookEvents runs your NewInspector event handlers.

ActiveInstance returns NULL.

3. The Toolbar Controls creates an instance of your control.

ActiveInstance returns NULL.

4. Outlook fires the built-in InspectorActivate event. Add-in Express handles it and fires the InspectorActivate event of ADXOutlookEvents.

ActiveInstance returns NULL.

5. The Toolbar Controls creates an instance of your control for the opened Inspector. ADXOutlookEvents runs your InspectorActivate event handlers.

ActiveInstance returns the instance of your control that was cloned from your original control.

Adding controls to Outlook toolbar <<

>> Controls for Outlook, Excel, Word, PowerPoint

Back to Toolbar Controls for Office homepage




Client login

 

Login 

Password 

 

Remember me

Forgot my password