O
orkdev
The vb6 code snippets below in a Outlook Add-in create:
1. a top level menu ("Vision Tools")
2. a menu item ("Enter email into Vision Patient Record")
3. a toolbar with one button
These are created only when a mail item is viewed
(as the Addin copies the body of a selected email into database at
request of user)
This looks fine in Office 2003.
However in Outlook 2007, both the Toolbar and the menu are shunted to
a tab marked Add-ins. This neither looks good nor is very intuitive
for the not so IT savvy. Is there any way to force the menu and/or the
Toolbar button onto the main ribbon?
############################################################
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 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
1. a top level menu ("Vision Tools")
2. a menu item ("Enter email into Vision Patient Record")
3. a toolbar with one button
These are created only when a mail item is viewed
(as the Addin copies the body of a selected email into database at
request of user)
This looks fine in Office 2003.
However in Outlook 2007, both the Toolbar and the menu are shunted to
a tab marked Add-ins. This neither looks good nor is very intuitive
for the not so IT savvy. Is there any way to force the menu and/or the
Toolbar button onto the main ribbon?
############################################################
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 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