O
orkdev
The following VB6 code adds a Toplevel Menu with a single menu item
to the menu of a MailItem in Outlook. The function of the Addin is to
copy the email body to a database, hence only wanting to add menu to
MailItem menu. It also creates a toolbar with a single button.
"Vision Tools"
-- "Enter email into Vision Patient Record"
The menu is created each time a new MailItem inspector is created (ie
Mail Item opened)
It is destroyed when the MailItem is closed
No problems with standalone Outlook 2003
The menu appears and functions correctly whenever a Mail Item is
opened including a new mail item
The problem occurs when Outlook 2003 is configured to work with *MS
Exchange*
Opening a received email - no problems
However when a New Mail is opened, the new menu appears multiple times
in the Mail Window eventually resulting in a ~~ error message. The
function of the Addin subsequently fails.
Checking for prior existence of menu before attempting to create the
menu makes no difference.
Any thoughts on where I am going astray or pointers to an alternative
approach gratefully received
TIA
Peter
####################################################
Public oMenuBar As Office.CommandBar
Public oMyControl As Office.CommandBarControl
Public WithEvents oMyCB As Office.CommandBarButton
Public oVisionToolBar As Office.CommandBar
Public WithEvents oMyCB2 As Office.CommandBarButton
Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
Dim objItem As Object
'On Error Resume Next
Set m_olMailItem = Nothing
Set objInsp = Inspector
Set objItem = objInsp.CurrentItem
Select Case objItem.Class
Case olMail
Set m_olMailItem = objItem
customiseOLMenu Inspector
Case Else
'
End Select
End Sub
Private Sub objInsp_Close()
'On Error Resume Next
oVisionToolBar.Delete
oMyControl.Delete
m_olApp.ActiveInspector.CommandBars.ActiveMenuBar.Reset
If m_olApp.ActiveExplorer Is Nothing And _
m_olApp.Inspectors.Count <= 1 Then
UnInitHandler
End If
End Sub
Private Sub customiseOLMenu(olIsp As Outlook.Inspector)
' Customize the Outlook Menu structure and toolbar.
Set oMenuBar = olIsp.CommandBars.ActiveMenuBar
Set oMyControl = oMenuBar.Controls.Add(msoControlPopup, , , 7,
True)
oMyControl.Caption = "Vision Tools"
Set oMyCB = oMyControl.Controls.Add( _
Type:=msoControlButton, Temporary:=True, Before:=1)
With oMyCB
.Caption = "Enter email into Vision Patient Record"
.Enabled = IsVisionRunning
End With
Set oVisionToolBar = olIsp.CommandBars.Add("Vision Tools", 1, ,
True)
With oVisionToolBar
.Visible = True
Set oMyCB2 = .Controls.Add(msoControlButton, , , , True)
End With
With oMyCB
.Caption = "Enter email into Vision Patient Record"
.DescriptionText = "Enter email into Vision Patient Record"
.Style = msoButtonIconAndCaption
.Picture = LoadResPicture(103, vbResBitmap)
End With
With oMyCB2
.Caption = "Enter email into Vision Patient Record"
.DescriptionText = "Enter email into Vision Patient Record"
.Style = msoButtonIcon
.Picture = LoadResPicture(103, vbResBitmap)
End With
With oVisionToolBar
.Protection = msoBarNoCustomize
End With
End Sub
to the menu of a MailItem in Outlook. The function of the Addin is to
copy the email body to a database, hence only wanting to add menu to
MailItem menu. It also creates a toolbar with a single button.
"Vision Tools"
-- "Enter email into Vision Patient Record"
The menu is created each time a new MailItem inspector is created (ie
Mail Item opened)
It is destroyed when the MailItem is closed
No problems with standalone Outlook 2003
The menu appears and functions correctly whenever a Mail Item is
opened including a new mail item
The problem occurs when Outlook 2003 is configured to work with *MS
Exchange*
Opening a received email - no problems
However when a New Mail is opened, the new menu appears multiple times
in the Mail Window eventually resulting in a ~~ error message. The
function of the Addin subsequently fails.
Checking for prior existence of menu before attempting to create the
menu makes no difference.
Any thoughts on where I am going astray or pointers to an alternative
approach gratefully received
TIA
Peter
####################################################
Public oMenuBar As Office.CommandBar
Public oMyControl As Office.CommandBarControl
Public WithEvents oMyCB As Office.CommandBarButton
Public oVisionToolBar As Office.CommandBar
Public WithEvents oMyCB2 As Office.CommandBarButton
Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
Dim objItem As Object
'On Error Resume Next
Set m_olMailItem = Nothing
Set objInsp = Inspector
Set objItem = objInsp.CurrentItem
Select Case objItem.Class
Case olMail
Set m_olMailItem = objItem
customiseOLMenu Inspector
Case Else
'
End Select
End Sub
Private Sub objInsp_Close()
'On Error Resume Next
oVisionToolBar.Delete
oMyControl.Delete
m_olApp.ActiveInspector.CommandBars.ActiveMenuBar.Reset
If m_olApp.ActiveExplorer Is Nothing And _
m_olApp.Inspectors.Count <= 1 Then
UnInitHandler
End If
End Sub
Private Sub customiseOLMenu(olIsp As Outlook.Inspector)
' Customize the Outlook Menu structure and toolbar.
Set oMenuBar = olIsp.CommandBars.ActiveMenuBar
Set oMyControl = oMenuBar.Controls.Add(msoControlPopup, , , 7,
True)
oMyControl.Caption = "Vision Tools"
Set oMyCB = oMyControl.Controls.Add( _
Type:=msoControlButton, Temporary:=True, Before:=1)
With oMyCB
.Caption = "Enter email into Vision Patient Record"
.Enabled = IsVisionRunning
End With
Set oVisionToolBar = olIsp.CommandBars.Add("Vision Tools", 1, ,
True)
With oVisionToolBar
.Visible = True
Set oMyCB2 = .Controls.Add(msoControlButton, , , , True)
End With
With oMyCB
.Caption = "Enter email into Vision Patient Record"
.DescriptionText = "Enter email into Vision Patient Record"
.Style = msoButtonIconAndCaption
.Picture = LoadResPicture(103, vbResBitmap)
End With
With oMyCB2
.Caption = "Enter email into Vision Patient Record"
.DescriptionText = "Enter email into Vision Patient Record"
.Style = msoButtonIcon
.Picture = LoadResPicture(103, vbResBitmap)
End With
With oVisionToolBar
.Protection = msoBarNoCustomize
End With
End Sub