Tried to create a ribbon with excel-dna and C#. The ribbon is not displayed in excel when the add-in is loaded.
dna file:
<DnaLibrary Name="falcon" RuntimeVersion="v4.0">
<ExternalLibrary Path="bin/Debug/falcon.dll" />
<!--<Reference AssemblyPath="System.Windows.Forms.dll" />-->
<CustomUI>
<customUI xmlns='http://schemas.microsoft.com/office/2009/07/customui' onLoad='OnLoad'>
<ribbon>
<tabs>
<tab id='CustomTab' label='My Tab' insertAfterMso='View'>
<group id='SampleGroup' label='My Group'>
<button id='LoginCmd' onAction='OnLogonPressed' label='logon' />
</group >
</tab>
</tabs>
</ribbon>
</customUI>
</CustomUI>
</DnaLibrary>
cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExcelDna.Integration;
using System.Runtime.InteropServices;
using ExcelDna.Integration.CustomUI;
namespace MyLibrary
{
[ComVisible(true)]
public class Ribbon : ExcelRibbon
{
private IRibbonUI ribbon = null;
public void OnLogonPressed(IRibbonControl control)
{
if (ribbon != null)
{
ribbon.InvalidateControl(control.Id);
}
}
public void OnLoad(IRibbonUI ribbon)
{
this.ribbon = ribbon;
}
}
}
I use Visual Studio Community Edition and the code compiles with .NET 4.6. I load the add-in by clicking directly on the xll file or by loading it in a new excel file. In excel the add-in tab is enabled and the macro security is on the lowest level. Furthermore I enabled under Settings
> Advanced
the option to show all errors for UI add-in's. I use excel 2010.
When I open excel the ribbon is not shown neither a error message. Anyone any suggestions?