在Excel中创建包含图像的库

时间:2015-02-05 14:17:44

标签: vb.net excel gallery ribbon

我试图像这样制作smth: enter image description here

现在我只使用imageMso属性进行测试。即便如此,也没有真正发生过。

这是图库的XML:

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <ribbon>
    <tabs>
      <tab idMso="TabAddIns" label="Gallery">
        <group id="grpGallery" label="Example Gallery">
          <gallery id="galleryID" label="My Gallery" columns="3" rows="2" size="large"
                   itemHeight="100" itemWidth="100"
                   getItemID="CallbackGetItemID"
                   getItemCount="CallbackGetItemsCount"
                   getItemImage="CallbackGetItemImage"
                   getItemScreentip="CallbackGetItemScreentip"
                   getItemSupertip="CallbackGetItemSupertip">
            <item id="galImg1" imageMso="PictureBrightnessGallery"/>
            <item id="galImg2" imageMso="ZoomPrintPreviewExcel"/>
          </gallery>

....

它的VB代码:

    Public idCounter As Integer

    Public Sub New()
        idCounter = 0
    End Sub

    Public Function GetCustomUI(ByVal ribbonID As String) As String Implements Office.IRibbonExtensibility.GetCustomUI
        Return GetResourceText("GalleryTest.Gallery.xml")
    End Function

#Region "Ribbon Callbacks"
    Public Sub Ribbon_Load(ByVal ribbonUI As Office.IRibbonUI)
        Me.galleryRibbon = ribbonUI
    End Sub

    Public Sub CallbackGetItemID(control As Microsoft.Office.Core.IRibbonControl, _
                                 index As Integer, ByRef itemID As Integer)
        itemID = idCounter
        idCounter += 1
    End Sub

    Public Sub CallbackGetItemsCount(control As Microsoft.Office.Core.IRibbonControl, _
                                        ByRef count As Integer)
        count = 6
    End Sub

    Public Sub CallbackGetItemScreentip(control As Microsoft.Office.Core.IRibbonControl, _
                                        Index As Integer, ByRef screentip As String)
        screentip = "Screentip"
    End Sub

    Public Sub CallbackGetItemSupertip(control As Microsoft.Office.Core.IRibbonControl, _
                                       Index As Integer, ByRef supertip As String)
        'TO DO'
    End Sub

如你所见,它没什么特别的。我刚刚进入vb.net + excel世界。会发生什么是我得到了#34;我的画廊&#34;下拉列表的按钮,在excel选项卡中,但它是空的。没有元素。甚至不是虚拟物品。

有什么建议吗?

P.S。我跟着this documentation

1 个答案:

答案 0 :(得分:0)

尝试在回调中返回实际值。例如,我在回调中看到不存在的ID。

如果您明确指定了项目,则无需为库控件添加 CallbackGetItemsCount 回调。

您可以在MSDN中的以下系列文章中阅读有关功能区UI的更多信息: