Ribbon issues "call to customUI() for RibbonID "Microsoft.Excel.Workbook" failed"

562 views
Skip to first unread message

Frank Halbach

unread,
Oct 23, 2014, 4:23:05 PM10/23/14
to exce...@googlegroups.com
Hi All,

I'm new to ExcelDna. It's an awesome tool!

I'm building a new tool and am currently stuck with the Ribbon...I want to add a Menu with 3 buttons.
I found good examples and links in this forum. I looked into FinAnSu's code for example.
 
However, when I launch my application in Excel 2013 I get this error message: "call to customUI() for RibbonID "Microsoft.Excel.Workbook" failed".




MyRibbon.XML:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" xmlns:x="myNameSpace">
  <ribbon>
    <tabs>
      <tab id='MyTab' label='My Addin'>
      </tab>
    </tabs>
  </ribbon>
</customUI>

RibbonClass.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using ExcelDna.Integration.CustomUI;
using System.Reflection;
using System.Runtime.InteropServices;


[ComVisible(true)]
public class MyRibbon : ExcelDna.Integration.CustomUI.ExcelRibbon
{

    public override string GetCustomUI(string uiName)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("MyLibrary.MyRibbon.xml"));

        return doc.InnerXml;
    }

}



Govert van Drimmelen

unread,
Oct 23, 2014, 4:43:41 PM10/23/14
to exce...@googlegroups.com
Hi Frank,

I'm not sure you need the XmlDocument at all. You should just be able to return the string from the resources.

As a test, could you replace the extraction from resources with a literal string returned from GetCustomUI()?
This worked fine for me (I just changed to single quotes to make the C# string easier).

    [ComVisible(true)]
    public class MyRibbon : ExcelDna.Integration.CustomUI.ExcelRibbon
    {

        public override string GetCustomUI(string uiName)
        {
            return 
@"<?xml version='1.0' encoding='UTF-8'?>
    <customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui' xmlns:x='myNameSpace'>
  <ribbon>
    <tabs>
      <tab id='MyTab' label='My Addin Test'>
      </tab>
    </tabs>
  </ribbon>
</customUI>";
        }

    }

I think something is going wrong between your resource embedding, the XmlDocument and the InnerXml.
I suggest you assign to a string before returning and check in a debugger.

-Govert
Reply all
Reply to author
Forward
0 new messages