Excel - 如何在使用XML创建的自定义功能区选项卡上使用自定义图标 [英] Excel - how to use a custom icon on a custom Ribbon tab created with XML

查看:316
本文介绍了Excel - 如何在使用XML创建的自定义功能区选项卡上使用自定义图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在创建Excel加载项以分发给我的用户。 加载项在使用XML创建的功能区上有一个自定义选项卡。

I am creating an Excel Add-in to distribute to my users.  The Add-in has a custom tab on the Ribbon created with XML.

我想在选项卡上使用我的自定义图标。 我该怎么做? 到目前为止,我只能使用Office附带的图标。 此外,我想以某种方式嵌入电子表格中的图标。

I want to use my custom icon on the tab. How do I do this?  So far, I can only use the icons that come with Office.  Also, I would like the icon embedded in the spreadsheet somehow.

这是我的一些代码....

Here is some of my code....

ribbonXML = ribbonXML +" imageMso ='计算器'     的OnAction =" GenReport" />" &安培; vbNewLine

ribbonXML = ribbonXML + "imageMso='Calculator'      onAction='GenReport'/>" & vbNewLine

如果我将计算器更改为MyCalculator,则不会显示图像。

If I change Calculator to MyCalculator, no image is displayed.

非常感谢任何帮助。

M.威尔逊

M. Wilson

M. Wilson

推荐答案

您好,

您可以使用图片功能区控件的 getImage 属性。图像属性s 指定控件的自定义图像。通常与  getImage  或  loadImage  回调。
在以下系列文章中阅读有关它们的更多信息:

You can use the image and getImage attributes for ribbon controls. The image attribute specifies the custom image for a control. Typically used with the getImage or loadImage callbacks. Read more about them in the following series of articles:

为开发人员自定义2007 Office Fluent功能区(第1部分,共3部分)

为开发人员自定义2007 Office Fluent功能区(第2部分,共3部分)

自定义2007适用于开发人员的Office Fluent功能区(第3部分,共3部分)

Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

基本上有两种方法可以动态加载图像。最简单的方法是使用  loadImage   回调,在  customUI   节点$ b $中定义b定制。或者,您可以处理  getImage   回调给定控制。

There are basically two ways to load images dynamically. The easiest way is to use the loadImage callback, which is defined in the customUI node of a customization. Alternatively, you can handle the getImage callback for a given control.

在自定义的根节点中,  customUI ,定义了一个名为  loadImage 。此回调
与控件上的image属性一起使用,并在Ribbon要求提供图像时调用。使用  loadImage   回调可以定义一张图片应用程序的
处理程序,并在图像属性中指定图像的名称。 

In the root node of a customization, customUI, there is a callback attribute defined called loadImage. This callback is used in conjunction with the image attribute on controls, and is called when the Ribbon asks for an image. Using the loadImage callbacks enables you to define one image handler for the application and specify the name of the image in the image attribute. 

而不是在  loadImage   中编写图像处理程序回调,许多控件还提供  getImage   回调
可用于设置控件的图像。当有关图像的信息存储在表格中并且您希望包含除图像属性中存储的文件名之外的图像的更多信息时,此回调非常有用。

Instead of writing an image handler in the loadImage callback, many controls also provide a getImage callback that can be used to set the image for the control. This callback is useful when information about the image is stored in a table and you want to include more information about the image besides the file name that is stored in the image attribute.

您可能还会发现以下文章有用:

You may also find the following articles helpful:

第11章:创建动态功能区自定义(1/2)

第11章:创建动态功能区自定义(2/2)


这篇关于Excel - 如何在使用XML创建的自定义功能区选项卡上使用自定义图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆