none
Cant override CreateRibbonExtensibilityObject() function and how to submit my XML then? RRS feed

  • Question

  • Hello,

    I'm creating a shared addin (not VSTO) for Outlook by using VS2010 and VB.NET. I selected .NET Framework 3.5 and managed it to get loaded by Outlook. So far, my Connect.vb is loaded and OnConnection() function is called.

    I also have a RibbonCode.vb which contains methods for the ribbon XML and I also have the XML embedded as ressource. The only thing missing is, that I cant assign my RibbonCode class to IRibbonExtensibility. I try it like this:

    Public Class Connect
      Implements Extensibility.IDTExtensibility2
      Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility
        Return New RibbonCode()
      End Function

    My RibbonCode.vb contains something like this:

    <ComVisible(True)> _ Public Class RibbonCode Implements IRibbonExtensibility Private ribbon As IRibbonUI Public Sub New() End Sub #Region "Initialization" Public Function GetCustomUI(ByVal ribbonID As String) As String Implements IRibbonExtensibility.GetCustomUI MsgBox("GetID: " & ribbonID) Select Case ribbonID ' Stuff to decide which XML to return End Select End Function #End Region

    Sadly, the IDE tells me for the override function for CreateRibbonExtensibilityObject() the following error:

    function 'CreateRibbonExtensibilityObject' cannot be declared 'Overrides' because it does not override a function in a base class.

    What am I doing wrong? I believe it is simply missing some "implements" or "using" clause, but which?

    Thanks for any help!


    Tuesday, October 8, 2013 10:20 AM

Answers

  • Hi,
    To create the UI extensibility for the ribbon in the Shared Add-In, the programmers need to implement two interfaces: Office.IRibbonExtensibility, Extensibility.IDTExtensibility2, and there are no CreateRibbonExtensibilityObject method in Extensibility.IDTExtensibility2 interface.

    public class Connect : Object, Extensibility.IDTExtensibility2, IRibbonExtensibility
    ...
    public string GetCustomUI(string RibbonID)
    {
       StreamReader customUIReader = new System.IO.StreamReader("C:\\RibbonXSampleCS\\customUI.xml");
       string customUIData = customUIReader.ReadToEnd();
       return customUIData;
    }


    You can refer to the following link to get more information.

    http://msdn.microsoft.com/en-us/library/office/aa433868%28v=office.12%29.aspx

    Regard & Thanks,

    • Marked as answer by Schlangengott Wednesday, October 9, 2013 2:44 PM
    Wednesday, October 9, 2013 2:00 PM

All replies

  • Hi,
    To create the UI extensibility for the ribbon in the Shared Add-In, the programmers need to implement two interfaces: Office.IRibbonExtensibility, Extensibility.IDTExtensibility2, and there are no CreateRibbonExtensibilityObject method in Extensibility.IDTExtensibility2 interface.

    public class Connect : Object, Extensibility.IDTExtensibility2, IRibbonExtensibility
    ...
    public string GetCustomUI(string RibbonID)
    {
       StreamReader customUIReader = new System.IO.StreamReader("C:\\RibbonXSampleCS\\customUI.xml");
       string customUIData = customUIReader.ReadToEnd();
       return customUIData;
    }


    You can refer to the following link to get more information.

    http://msdn.microsoft.com/en-us/library/office/aa433868%28v=office.12%29.aspx

    Regard & Thanks,

    • Marked as answer by Schlangengott Wednesday, October 9, 2013 2:44 PM
    Wednesday, October 9, 2013 2:00 PM
  • Hi Marvin,

    thank you! I got it to run with this but it looks like I simply can not implement IRibbonExtensibility in another class then Connect.vb. I had it in my RibbonCode.vb but it was ignored there. Do I need to copy all my ribbon code to Connect.vb or is there a way to implement IRibbonExtensibility in another class than Connect.vb?

    Kind Regards

    Wednesday, October 9, 2013 2:44 PM
  • The requirement is to be in the same class that implements Extensibilty and is a public class in scope.

    I usually keep my ribbon code in a separate file that shares the same class name. For example in Connect.vb something like this:

    Imports Office = Microsoft.Office.Core

    Partial Public Class Connect

      Implements Extensibility.IDTExtensibility2

    and in RibbonX.vb:

    Partial Public Class Connect

      Implements Office.IRibbonExtensibility



    Ken Slovak MVP - Outlook



    Wednesday, October 9, 2013 8:37 PM
    Moderator
  • This was exactly what I needed! I also like to split ribbon related code from the initial class.

    Thank you Ken!

    Kind Regards

    Thursday, October 10, 2013 7:01 AM