Outlook 2007 Menus and Toolbars

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
 
K

Ken Slovak - [MVP - Outlook]

To use the ribbon you need to provide ribbon XML in the same class that
handles the extensibility interfaces. You must handle the ribbon interfaces
through a series of callbacks specified in your XML.

I have a VB6 template for Outlook 2007 that handles the ribbon, you can
download that and see how that sort of thing is handled in VB6. My template
is at http://www.slovaktech.com/outlook_2007_templates.htm.

There isn't that much else around in the way of VB6 samples, most
Outlook/Office 2007 addin and ribbon samples are written using C# or VB.NET.
 
O

orkdev

Thanks Ken,

I'll take a look at that

Peter
VB6 Dinosaur

To use the ribbon you need to provide ribbon XML in the same class that
handles the extensibility interfaces. You must handle the ribbon interfaces
through a series of callbacks specified in your XML.

I have a VB6 template for Outlook 2007 that handles the ribbon, you can
download that and see how that sort of thing is handled in VB6. My template
is athttp://www.slovaktech.com/outlook_2007_templates.htm.

There isn't that much else around in the way of VB6 samples, most
Outlook/Office 2007 addin and ribbon samples are written using C# or VB.NET.

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm




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- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top