I am converting an old dna file to visual basic .net, to allow for use in Excel 64 bit
The ribbon used to show in the 32 bit version (a simple msgbox to change a default value) but the ribbon is not showing in the new version.
I am using VS 2017.
Code used to create ribbon:
' Can make a class that implements ExcelDna.Integration.CustomUI.ExcelRibbon
' to get full Ribbon access.
Public Class MyRibbon
Inherits ExcelRibbon
Public Sub OnButtonPressed(control As IRibbonControl)
SetDefault()
End Sub
End Class
code in the dna file for the ribbon:
<CustomUI>
<!-- Inside here is the RibbonX xml passed to Excel -->
<customUI xmlns = "http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso = "TabAddIns" >
<group idQ="x:ORSErlang64" label="ORSErlang64">
<button id="C1" label="Set Default" size="large"
imageMso="StartAfterPrevious" onAction="OnButtonPressed"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
</CustomUI>
I can't figure out what I am doing wrong, and most examples I can find on the web are c#, not vb.net
The issue is that you are declaring the ID of the group as idQ="x:ORSErlang64"
but you are not declaring what the namespace x
is.
On the customUI
element, you need to define the x
namespace such as <customUI xmlns="..." xmlns:x="http://yourapp.com">
For example:
<DnaLibrary RuntimeVersion="v4.0" Name="Ribbon Tests" Description="Ribbon Tests Description (not used)">
<![CDATA[
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Core
Imports ExcelDna.Integration.CustomUI
<ComVisible(True)> _
Public Class MyRibbon
Inherits ExcelRibbon
Public Sub OnButtonPressed(control as IRibbonControl)
MsgBox("My Button Pressed on control " & control.Id,, "ExcelDna Ribbon!")
End Sub
End Class
]]>
<CustomUI>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
xmlns:x="http://caioproiete.net">
<ribbon>
<tabs>
<tab idMso="TabAddIns">
<group idQ="x:ORSErlang64" label="ORSErlang64">
<button id="C1" label="Set Default" size="large"
imageMso="StartAfterPrevious" onAction="OnButtonPressed" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
</CustomUI>
</DnaLibrary>