Welcome to the horrible world of creating Outlook addins that work for both 2003 and 2007.
People have commented that wordmail has a horrible side effect in Word 2003, where toolbars used in Outlook inspectors show up in Word. See the this Kevin Slovak’s discussion of the problem in the links section.
Anyway, the workaround mentioned in the article doesn’t work (of course) in Outlook 2007. It is therefore necessary to check the version of Word (which doesn’t have toolbars) for the code to work for both versions.
It makes me wish Microsoft would hand out free office upgrades.
Anyway, here’s the complete code:
' Listen for inspector activate
Private WithEvents moWord As Microsoft.Office.Interop.Word.Application
Private moInspector As Inspector
Private Sub moWord_WindowActivate(ByVal Doc As Microsoft.Office.Interop.Word.Document, ByVal Wn As Microsoft.Office.Interop.Word.Window) Handles moWord.WindowActivate
If Wn.EnvelopeVisible AndAlso moInspector IsNot Nothing Then
moInspector = Nothing
moWord = Nothing
If Doc.AttachedTemplate IsNot Nothing Then Doc.AttachedTemplate.Saved = True
Private Sub moInspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles moInspectors.NewInspector
Dim lbRaiseEvents As Boolean = True
If Inspector.IsWordMail Then
' HACK: Wordmail does not work in the same way in
' Word 2008 as it does in 2003. I think this
' may be because of the lack of real toolbars
' in Word 2007.
If Val(Inspector.WordEditor.Application.Version) < 12 Then
moInspector = Inspector
moWord = Inspector.WordEditor.Application
lbRaiseEvents = False
If lbRaiseEvents Then mShowInspector(Inspector)
This code is provided in case some poor soul out there gets the problem as well.