In Office 2007 there are 3 available color schemes – Black, Blue and Silver. The background of controls in command bars and ribbon tabs is changed by Microsoft Office automatically. Do you want to try changing the background of your Outlook forms and Excel task panes when the MS Office color scheme is changed?
Add-in Express has all needed stuff except for the color to fill the background. Firstly, we’ll need the OfficeColorSchemeChanged event handler in which we forcibly change the background of all our custom forms:
Private Sub AddinModule_OfficeColorSchemeChanged( _
ByVal sender As System.Object, _
ByVal theme As AddinExpress.MSO.OfficeColorScheme) _
Handles MyBase.OfficeColorSchemeChanged
' Excel task pane
If Me.HostType = AddinExpress.MSO.ADXOfficeHostApp.ohaExcel Then
Dim ExcelPane As ADXExcelTaskPane1
ExcelPane = CType( _
ExcelTaskPanesCollectionItem.TaskPaneInstance, _
ADXExcelTaskPane1)
ExcelPane.DoPaint(theme)
End If
' Outlook forms
If Me.HostType = AddinExpress.MSO.ADXOfficeHostApp.ohaOutlook Then
Dim OutlookForm As ADXOlForm1
Dim I As Integer
For I = 0 To OlFormsCollectionItem.FormInstanceCount - 1
OutlookForm = CType( _
OlFormsCollectionItem.FormInstances(I), _
ADXOlForm1)
OutlookForm.DoPaint(theme)
Next
End If
End Sub
Secondly, your custom form, or a task pane, needs to be able to paint its background before it shows up:
Private Sub ADXExcelTaskPane1_ADXBeforeTaskPaneShow( _
ByVal sender As System.Object, _
ByVal e As AddinExpress.XL.ADXBeforeTaskPaneShowEventArgs) _
Handles MyBase.ADXBeforeTaskPaneShow
DoPaint(CType (AddinModule, AddinModule).OfficeColorScheme)
End Sub
Private Sub ADXOlForm1_ADXBeforeFormShow() Handles _
MyBase.ADXBeforeFormShow
DoPaint(CType(AddinModule, AddinModule).OfficeColorScheme)
End Sub
And here is the key point – colors:
- Black – &HEBEBEB (0xEBEBEB)
- Blue – &HD5E4F2 (0xD5E4F2)
- Silver – &HEEEEF4 (0xEEEEF4)
Public Sub DoPaint(ByVal theme As _
AddinExpress.MSO.OfficeColorScheme)
Select Case theme
Case AddinExpress.MSO.OfficeColorScheme.Black
Me.BackColor = Color.FromArgb(&HEB, &HEB, &HEB)
Case AddinExpress.MSO.OfficeColorScheme.Blue
Me.BackColor = Color.FromArgb(&HD5, &HE4, &HF2)
Case AddinExpress.MSO.OfficeColorScheme.Silver
Me.BackColor = Color.FromArgb(&HEE, &HEE, &HF4)
Case AddinExpress.MSO.OfficeColorScheme.Unknown
Me.BackColor = SystemColors.Control
End Select
End Sub
And that seems to be all! If you have any questions or comments, you are most welcome!
You may also be interested in:
Advanced Outlook form and view regions
Customization of Reading pane, Outlook bar and To-Do bar
Zero visibility for Outlook forms
Outlook forms: minimized, expanded, hidden
Available downloads:
The sample add-ins below were written using Add-in Express for Office and .net
C# sample Outlook and Excel add-in for VS 2005
VB.NET sample Outlook and Excel add-in for VS 2005





