【问题标题】:ExcelDna not showing custom ribbon in AddInExcelDna 未在 AddIn 中显示自定义功能区
【发布时间】:2018-02-02 17:59:57
【问题描述】:

我正在将一个旧的 dna 文件转换为 Visual Basic .net,以便在 Excel 64 位中使用

用于在 32 位版本中显示的功能区(用于更改默认值的简单 msgbox)但功能区未在新版本中显示。

我正在使用 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

【问题讨论】:

    标签: vb.net visual-studio-2017 excel-2013 excel-dna


    【解决方案1】:

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

    customUI元素上,需要定义x命名空间如&lt;customUI xmlns="..." xmlns:x="http://yourapp.com"&gt;

    例如:

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

    【讨论】:

      猜你喜欢
      • 2012-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      • 1970-01-01
      • 2018-01-24
      • 2020-07-17
      • 1970-01-01
      相关资源
      最近更新 更多