5

I have an Outlook Task Pane that opens when you open Outlook and I have added this using this approach.

https://msdn.microsoft.com/en-us/library/aa942846.aspx

I am showing and hiding the Task Pane using the example given here:

https://msdn.microsoft.com/en-us/library/bb608590.aspx

So, this works with an email when the user clicks on the toggle button. However, I have added another ribbon control on the New Mail Message window of Outlook and I would like this same Task Pane to be available on the side of that window as well. I managed to create another ribbon control (designer) and added this new button but when I toggle it, it does not open a task pane on the new mail message window. It only toggles the existing task pane window that is available in the inbox.

Code for the New Mail Message Ribbon Control:

Imports Microsoft.Office.Tools.Ribbon
Imports Outlook = Microsoft.Office.Interop.Outlook
Imports Microsoft.Office.Tools

Public Class ComposeSidebarRibbon

    Private Sub ComposeSidebarRibbon_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load

    End Sub

    Private Sub SidebarToggleButton_Click(sender As Object, e As RibbonControlEventArgs) Handles SidebarToggleButton.Click
        Globals.ThisAddIn.TaskPane.Visible = TryCast(sender, Microsoft.Office.Tools.Ribbon.RibbonToggleButton).Checked
    End Sub
End Class

How can I go about doing this?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Neophile
  • 5,660
  • 14
  • 61
  • 107

1 Answers1

1

As per MSDN you can add more than one ribbon by using different id's for the ribbons -

You can add more than one ribbon to a project. If more than one ribbon shares a ribbon ID, override the CreateRibbonExtensibilityObject method in the ThisAddin class of your project to specify which ribbon to display at run time.

The function to use for this will be similar to -

Protected Overrides Function CreateRibbonExtensibilityObject() As  _
    Microsoft.Office.Core.IRibbonExtensibility
    If myCondition = True Then
        Return Globals.Factory.GetRibbonFactory().CreateRibbonManager _
            (New Microsoft.Office.Tools.Ribbon.IRibbonExtension() _
                 {New Ribbon1()})
    Else
        Return Globals.Factory.GetRibbonFactory().CreateRibbonManager _
            (New Microsoft.Office.Tools.Ribbon.IRibbonExtension() _
                 {New Ribbon2()})
    End If
End Function

Please see the MSDN reference HERE

AlwaysConfused
  • 450
  • 4
  • 13
  • And what would myCondition be in the case I mentioned above? – Neophile Jan 28 '17 at 23:12
  • I don't think you understood what I meant, basically its the Task Pane that is not showing in the New Mail message window. My Ribbon controls are behaving and working as expected. – Neophile Jan 28 '17 at 23:15
  • I do apologize, must have misunderstood - See this link https://msdn.microsoft.com/en-us/library/bb608622(v=vs.100).aspx or this one https://msdn.microsoft.com/en-us/library/bb296010(v=vs.100).aspx – AlwaysConfused Jan 29 '17 at 09:38
  • Well, I think the first link seems to be what I would need but could I perform a different action on the 2nd ribbon control? – Neophile Jan 29 '17 at 21:51