ExcelDna 未在加载项中显示自定义功能区

ExcelDna not showing custom ribbon in AddIn

我正在将旧的 dna 文件转换为 visual basic .net,以便在 Excel 64 位

中使用

以前在 32 位版本中显示的功能区(更改默认值的简单消息框)但功能区在新版本中不显示。

我使用的是 VS 2017。

用于创建功能区的代码:

' 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

色带 dna 文件中的代码:

<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>

我不知道我做错了什么,我在网上找到的大多数例子都是 c#,而不是 vb.net

问题是您将组的 ID 声明为 idQ="x:ORSErlang64",但没有声明命名空间 x 是什么。

customUI元素上,需要定义x命名空间,例如<customUI xmlns="..." xmlns:x="http://yourapp.com">

例如:

<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>