未分类

VBA VB6 C# C++ Ribbon回调差异(对使用VB6写EXCEL插件来说很重要)

参见:https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/aa722523(v=office.12)

How can I determine the correct signatures for each callback procedure?

The following table lists all of the callbacks, along with their procedure signatures for C++, VBA, C#, and Visual Basic.

Table 4. List of all C#, VBA, C++, and Visual Basic callbacks and signatures

Control

Callback Name

Signatures

(several controls)

getDescription

C#: string GetDescription(IRibbonControl control)

VBA: Sub GetDescription(control As IRibbonControl, ByRef description)

C++: HRESULT GetDescription([in] IRibbonControl *pControl, [out, retval] BSTR *pbstr Description)

Visual Basic: Function GetDescription(control As IRibbonControl) As String

(several controls)

getEnabled

C#: bool GetEnabled(IRibbonControl control)

VBA: Sub GetEnabled(control As IRibbonControl, ByRef enabled)

C++: HRESULT GetEnabled([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfEnabled)

Visual Basic: Function GetEnabled(control as IRibbonControl) As Boolean

(several controls)

getImage

C#: IPictureDisp GetImage(IRibbonControl control)

VBA: Sub GetImage(control As IRibbonControl, ByRef image)

C++: HRESULT GetImage([in] IRibbonControl *pControl, [out, retval] IPictureDisp ** ppdispImage)

Visual Basic: Function GetImage(control as IRibbonControl) as IPictureDisp

(several controls)

getImageMso

C#: string GetImageMso(IRibbonControl control)

VBA: Sub GetImageMso(control As IRibbonControl, ByRef imageMso)

C++: HRESULT GetImageMso([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrImageMso)

Visual Basic: Function GetImageMso(control as IRibbonControl) as String

(several controls)

getLabel

C#: string GetLabel(IRibbonControl control)

VBA: Sub GetLabel(control As IRibbonControl, ByRef label)

C++: HRESULT GetLabel([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrLabel)

Visual Basic: Function GetLabel(control As IRibbonControl) As String

(several controls)

getKeytip

C#: string GetKeytip(IRibbonControl control)

VBA: Sub GetKeytip (control As IRibbonControl, ByRef label)

C++: HRESULT GetKeytip ([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrKeytip)

Visual Basic: Function GetKeytip (control As IRibbonControl) As String

(several controls)

getSize

C#: RibbonControlSize GetSize(IRibbonControl control)

VBA: sub GetSize(control As IRibbonControl, ByRef size)

C++: HRESULT GetSize([in] IRibbonControl *pControl, [out, retval] RibbonControlSize *pintSize)

Visual Basic: Function GetSize(control As IRibbonControl) As RibbonControlSize

(several controls)

getScreentip

C#: string GetScreentip(IRibbonControl control)

VBA: Sub GetScreentip(control As IRibbonControl, ByRef screentip)

C++: HRESULT GetScreentip([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrScreentip)

Visual Basic: Function GetScreentip(control As IRibbonControl) As String

(several controls)

getSupertip

C#: string GetSupertip(IRibbonControl control)

VBA: Sub GetSupertip(control As IRibbonControl, ByRef screentip)

C++: HRESULT GetSupertip([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrScreentip)

Visual Basic: Function GetSupertip(control As IRibbonControl) As String

(several controls)

getVisible

C#: bool GetVisible(IRibbonControl control)

VBA: Sub GetVisible(control As IRibbonControl, ByRef visible)

C++: HRESULT GetVisible([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfVisible)

Visual Basic: Function GetVisible(control As IRibbonControl) As Boolean

button

getShowImage

C#: bool GetShowImage(IRibbonControl control)

VBA: Sub GetShowImage (control As IRibbonControl, ByRef showImage)

C++: HRESULT GetShowImage ([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarShowImage)

Visual Basic: Function GetShowImage (control As IRibbonControl) As Boolean

button

getShowLabel

C#: bool GetShowLabel(IRibbonControl control)

VBA: Sub GetShowLabel (control As IRibbonControl, ByRef showLabel)

C++: HRESULT GetShowLabel ([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarShowLabel)

Visual Basic: Function GetShowLabel (control As IRibbonControl) As Boolean

button

onAction – repurposed

C#: void OnAction(IRibbonControl control, ref bool CancelDefault)

VBA: Sub OnAction(control As IRibbonControl, byRef CancelDefault)

C++: HRESULT OnAction([in] IRibbonControl *pControl, [in,out] VARIANT _BOOL *fCancelDefault)

Visual Basic: Sub OnAction(control As IRibbonControl, byRef CancelDefault)

button

onAction

C#: void OnAction(IRibbonControl control)

VBA: Sub OnAction(control As IRibbonControl)

C++: HRESULT OnAction([in] IRibbonControl *pControl)

Visual Basic: Sub OnAction(control As IRibbonControl)

checkBox

getPressed

C#: bool GetPressed(IRibbonControl control)

VBA: Sub GetPressed(control As IRibbonControl, ByRef returnValue)

C++: HRESULT GetPressed([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfPressed)

Visual Basic: Function GetPressed(control As IRibbonControl) As Boolean

checkBox

onAction

C#: void OnAction(IRibbonControl control, bool pressed)

VBA: Sub OnAction(control As IRibbonControl, pressed As Boolean)

C++: HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed)

Visual Basic: Sub OnAction(control As IRibbonControl, pressed As Boolean)

comboBox

getItemCount

C#: int GetItemCount(IRibbonControl control)

VBA: Sub GetItemCount(control As IRibbonControl, ByRef count)

C++: HRESULT GetItemCount([in] IRibbonControl *pControl, [out, retval] long *count)

Visual Basic: Function GetItemCount(control As IRibbonControl) As Integer

comboBox

getItemID

C#: string GetItemID(IRibbonControl control, int index)

VBA: Sub GetItemID(control As IRibbonControl, index As Integer, ByRef id)

C++: HRESULT GetItemID([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrID)

Visual Basic: Function GetItemID(control As IRibbonControl, index As Integer) As String

comboBox

getItemImage

C#: IPictureDisp GetItemImage(IRibbonControl control, int index)

VBA: Sub GetItemImage(control As IRibbonControl, index As Integer, ByRef image)

C++: HRESULT GetItemImage([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] IPictureDisp **ppdispImage)

Visual Basic: Function GetItemImage(control As IRibbonControl, index As Integer) As IPictureDisp

comboBox

getItemLabel

C#: string GetItemLabel(IRibbonControl control, int index)

VBA: Sub GetItemLabel(control As IRibbonControl, index As Integer, ByRef label)

C++: HRESULT GetItemLabel([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrLabel)

Visual Basic: Function GetItemLabel(control As IRibbonControl, index As Integer) As String

comboBox

getItemScreenTip

C#: string GetItemScreenTip(IRibbonControl control, int index)

VBA: Sub GetItemScreenTip(control As IRibbonControl, index As Integer, ByRef screentip)

C++: HRESULT GetItemScreentip([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrScreentip)

Visual Basic: Function GetItemScreentip(control As IRibbonControl, index As Integer) As String

comboBox

getItemSuperTip

C#: string GetItemSuperTip(IRibbonControl control, int index)

VBA: Sub GetItemSuperTip (control As IRibbonControl, index As Integer, ByRef supertip)

C++: HRESULT GetItemSuperTip ([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrScreentip)

Visual Basic: Function GetItemSuperTip (control As IRibbonControl, index As Integer) As String

comboBox

getText

C#: string GetText(IRibbonControl control)

VBA: Sub GetText(control As IRibbonControl, ByRef text)

C++: HRESULT GetText([in] IRibbonControl *pControl, [out, reval] BSTR *pbstrText)

Visual Basic: Function GetText(control As IRibbonControl) As String

comboBox

onChange

C#: void OnChange(IRibbonControl control, string text)

VBA: Sub OnChange(control As IRibbonControl, text As String)

C++: HRESULT OnChange([in] IRibbonControl *pControl, [in] BSTR *pbstrText)

Visual Basic: Sub OnChange(control As IRibbonControl, text As String)

customUI

loadImage

C#: IPictureDisp LoadImage(string image_id)

VBA: Sub LoadImage(imageId As string, ByRef image)

C++: HRESULT LoadImage([in] BSTR *pbstrImageId, [out, retval] IPictureDisp ** ppdispImage)

Visual Basic: Function LoadImage(imageId As String) As IPictureDisp

customUI

onLoad

C#: void OnLoad(IRibbonUI ribbon)

VBA: Sub OnLoad(ribbon As IRibbonUI)

C++: HRESULT OnLoad([in] IRibbonUI *pRibbon)

Visual Basic: Function OnLoad(ribbon As IRibbonUI)

dropDown

getItemCount

C#: int GetItemCount(IRibbonControl control)

VBA: Sub GetItemCount(control As IRibbonControl, ByRef count)

C++: HRESULT GetItemCount([in] IRibbonControl *pControl, [out, retval] long *count)

Visual Basic: Function GetItemCount(control As IRibbonControl) As Integer

dropDown

getItemID

C#: string GetItemID(IRibbonControl control, int index)

VBA: Sub GetItemID(control As IRibbonControl, index As Integer, ByRef id)

C++: HRESULT GetItemID([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrID)

Visual Basic: Function GetItemID(control As IRibbonControl, index As Integer) As String

dropDown

getItemImage

C#: IPictureDisp GetItemImage(IRibbonControl control, int index)

VBA: Sub GetItemImage(control As IRibbonControl, index As Integer, ByRef image)

C++: HRESULT GetItemImage([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] IPictureDisp **ppdispImage)

Visual Basic: Function GetItemImage(control As IRibbonControl, index As Integer) As IPictureDisp

dropDown

getItemLabel

C#: string GetItemLabel(IRibbonControl control, int index)

VBA: Sub GetItemLabel(control As IRibbonControl, index As Integer, ByRef label)

C++: HRESULT GetItemLabel([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrLabel)

Visual Basic: Function GetItemLabel(control As IRibbonControl, index As Integer) As String

dropDown

getItemScreenTip

C#: string GetItemScreenTip(IRibbonControl control, int index)

VBA: Sub GetItemScreenTip(control As IRibbonControl, index As Integer, ByRef screenTip)

C++: HRESULT GetItemScreentip([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrScreentip)

Visual Basic: Function GetItemScreentip(control As IRibbonControl, index As Integer) As String

dropDown

getItemSuperTip

C#: string GetItemSuperTip(IRibbonControl control, int index)

VBA: Sub GetItemSuperTip (control As IRibbonControl, index As Integer, ByRef superTip)

C++: HRESULT GetItemSuperTip ([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrSupertip)

Visual Basic: Function GetItemSuperTip (control As IRibbonControl, index As Integer) As String

dropDown

getSelectedItemID

C#: string GetSelectedItemID(IRibbonControl control)

VBA: Sub GetSelectedItemID(control As IRibbonControl, ByRef index)

C++: HRESULT GetSelectedItemID([in] IRibbonControl *pControl, [out, retval] LONG *pcItemIndex)

Visual Basic: Function GetSelectedItemID(control As IRibbonControl) As Integer

dropDown

getSelectedItemIndex

C#: int GetSelectedItemIndex(IRibbonControl control)

VBA: Sub GetSelectedItemIndex(control As IRibbonControl, ByRef index)

C++: HRESULT GetSelectedItemIndex([in] IRibbonControl *pControl, [out, retval] LONG *pcItemIndex)

Visual Basic: Function GetSelectedItemIndex(control As IRibbonControl) As Integer

dropDown

onAction

C#: void OnAction(IRibbonControl control, string selectedId, int selectedIndex)

VBA: Sub OnAction(control As IRibbonControl, selectedId As String, selectedIndex As Integer)

C++: HRESULT OnAction([in] IRibbonControl *pControl, [in] BSTR *selectedId, [in] LONG cSelectedIndex)

Visual Basic: Sub OnAction(control As IRibbonControl, selectedId As String, selectedIndex As Integer)

dynamicMenu

getContent

C#: string GetContent(IRibbonControl control)

VBA: Sub GetContent(control As IRibbonControl, ByRef content)

C++: HRESULT GetContent([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrContent)

Visual Basic: Function GetContent(control As IRibbonControl) As String

editBox

getText

C#: string GetText(IRibbonControl control)

VBA: Sub GetText(control As IRibbonControl, ByRef text)

C++: HRESULT GetText([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrText)

Visual Basic: Function GetText(control As IRibbonControl) As String

editBox

onChange

C#: void OnChange(IRibbonControl control, string text)

VBA: Sub OnChange(control As IRibbonControl, text As String)

C++: HRESULT OnChange([in] IRibbonControl *pControl, [in] BSTR *pbstrText)

Visual Basic: Sub OnChange(control As IRibbonControl, text As String)

gallery

getItemCount

C#: int GetItemCount(IRibbonControl control)

VBA: Sub GetItemCount(control As IRibbonControl, ByRef count)

C++: HRESULT GetItemCount([in] IRibbonControl *pControl, [out, retval] long *count)

Visual Basic: Function GetItemCount(control As IRibbonControl) As Integer

gallery

getItemHeight

C#: int getItemHeight(IRibbonControl control)

VBA: Sub getItemHeight(control As IRibbonControl, ByRef height)

C++: HRESULT getItemHeight([in] IRibbonControl *pControl, [out, retval] LONG *height)

Visual Basic: Function getItemHeight(control As IRibbonControl) As Integer

gallery

getItemID

C#: string GetItemID(IRibbonControl control, int index)

VBA: Sub GetItemID(control As IRibbonControl, index As Integer, ByRef id)

C++: HRESULT GetItemID([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrID)

Visual Basic: Function GetItemID(control As IRibbonControl, index As Integer) As String

gallery

getItemImage

C#: IPictureDisp GetItemImage(IRibbonControl control, int index)

VBA: Sub GetItemImage(control As IRibbonControl, index As Integer, ByRef image)

C++: HRESULT GetItemImage([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] IPictureDisp **ppdispImage)

Visual Basic: Function GetItemImage(control As IRibbonControl, index As Integer) As IPictureDisp

gallery

getItemLabel

C#: string GetItemLabel(IRibbonControl control, int index)

VBA: Sub GetItemLabel(control As IRibbonControl, index As Integer, ByRef label)

C++: HRESULT GetItemLabel([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrLabel)

Visual Basic: Function GetItemLabel(control As IRibbonControl, index As Integer) As String

gallery

getItemScreenTip

C#: string GetItemScreenTip(IRibbonControl control, int index)

VBA: Sub GetItemScreenTip(control As IRibbonControl, index as Integer, ByRef screen)

C++: HRESULT GetItemScreentip([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrScreentip)

Visual Basic: Function GetItemScreentip(control As IRibbonControl, index As Integer) As String

gallery

getItemSuperTip

C#: string GetItemSuperTip(IRibbonControl control, int index)

VBA: Sub GetItemSuperTip (control As IRibbonControl, index as Integer, ByRef screen)

C++: HRESULT GetItemSuperTip ([in] IRibbonControl *pControl, [in] long cIndex, [out, retval] BSTR *pbstrSupertip)

Visual Basic: Function GetItemSuperTip (control As IRibbonControl, index As Integer) As String

gallery

getItemWidth

C#: int getItemWidth(IRibbonControl control)

VBA: Sub getItemWidth(control As IRibbonControl, ByRef width)

C++: HRESULT getItemWidth([in] IRibbonControl *pControl, [out, retval] LONG *width)

Visual Basic: Function getItemWidth(control As IRibbonControl) As Integer

gallery

getSelectedItemID

C#: int GetSelectedItemID(IRibbonControl control)

VBA: Sub GetSelectedItemID(control As IRibbonControl, ByRef index)

C++: HRESULT GetSelectedItemID([in] IRibbonControl *pControl, [out, retval] LONG *pcItemIndex)

Visual Basic: Function GetSelectedItemID(control As IRibbonControl) As Integer

gallery

getSelectedItemIndex

C#: int GetSelectedItemIndex(IRibbonControl control)

VBA: Sub GetSelectedItemIndex(control As IRibbonControl, ByRef index)

C++: HRESULT GetSelectedItemIndex([in] IRibbonControl *pControl, [out, retval] LONG *pcItemIndex)

Visual Basic: Function GetSelectedItemIndex(control As IRibbonControl) As Integer

gallery

onAction

C#: void OnAction(IRibbonControl control, string selectedId, int selectedIndex)

VBA: Sub OnAction(control As IRibbonControl, selectedId As String, selectedIndex As Integer)

C++: HRESULT OnAction([in] IRibbonControl *pControl, [in] BSTR *selectedId, [in] LONG cSelectedIndex)

Visual Basic: Sub OnAction(control As IRibbonControl, selectedId As String, selectedIndex As Integer)

menuSeparator

getTitle

C#: string GetTitle(IRibbonControl control)

VBA: Sub GetTitle (control As IRibbonControl, ByRef title)

C++: HRESULT GetTitle ([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrTitle)

Visual Basic: Function GetTitle (control As IRibbonControl) As String

toggleButton

getPressed

C#: bool GetPressed(IRibbonControl control)

VBA: Sub GetPressed(control As IRibbonControl, ByRef returnValue)

C++: HRESULT GetPressed([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfPressed)

Visual Basic: Function GetPressed(control As IRibbonControl) As Boolean

toggleButton

onAction – repurposed

C#: void OnAction(IRibbonControl control, bool pressed, ref bool cancelDefault)

VBA: Sub OnAction(control As IRibbonControl, pressed As Boolean, byRef cancelDefault)

C++: HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed, [in,out] VARIANT _BOOL *fCancelDefault)

Visual Basic: Sub OnAction(control As IRibbonControl, pressed As Boolean, byRef CancelDefault)

toggleButton

onAction

C#: void OnAction(IRibbonControl control, bool pressed)

VBA: Sub OnAction(control As IRibbonControl, pressed As Boolean)

C++: HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed)

Visual Basic: Sub OnAction(control As IRibbonControl, pressed As Boolean)

How do I find out what each Ribbon attribute indicates?

The following table lists all of the Ribbon attributes and includes a short description of each.

Table 5. Ribbon attributes

Attribute

Type or value

Description

description

String

Specifies description text that is displayed in menus when the itemSize attribute is set to large.

enabled

true, false, 0, 1

Specifies whether the control is enabled.

getContent

callback

For a dynamic menu, retrieves XML content that describes the menu.

getDescription

callback

Gets the description of a control.

getEnabled

callback

Gets the enabled state of a control.

getImage

callback

Gets the image for this control.

getImageMso

callback

Gets a built-in control’s icon by using the control ID.

getItemCount

callback

For a combo box, drop-down list, or gallery, gets the number of items to be displayed.

getItemID

callback

For a combo box, drop-down list, or gallery, gets the ID for a specific item.

getItemImage

callback

For a combo box, drop-down list, or gallery, gets the image for a specific item.

getItemLabel

callback

For a combo box, drop-down list, or gallery, gets the label for a specific item.

getItemScreentip

callback

For a combo box, drop-down list, or gallery, gets the ScreenTip for a specific item.

getItemSupertip

callback

For a combo box, drop-down list, or gallery, gets the Enhanced ScreenTip for a specific item.

getKeytip

callback

Gets the KeyTip for a control.

getLabel

callback

Gets the label for a control.

getPressed

callback

For a toggle button, gets a value that indicates whether the state is pressed or not pressed.

For a check box, gets a value that indicates whether the state is selected or cleared.

getScreentip

callback

Gets the ScreenTip for a control.

getSelectedItemID

callback

For a drop-down list or gallery, gets the ID of the selected item.

getSelectedItemIndex

callback

For a drop-down list or gallery, gets the index of the selected item.

getShowImage

callback

Gets a value that specifies whether to display the control image.

getShowLabel

callback

Gets a value that specifies whether to display the control label.

getSize

callback

Gets a value that specifies the size of a control (normal or large).

getSupertip

callback

Gets a value that specifies the Enhanced ScreenTip for a control.

getText

callback

For a text box or edit box, gets the text to be displayed in the edit portion of the control.

getTitle

callback

For a menu separator, gets the text to be displayed (rather than a horizontal line).

getVisible

callback

Gets a value that specifies whether the control is visible.

id

String

A user-defined unique identifier for the control (mutually exclusive with idMso and idQ—specify only one of these values).

idMso

control id

Built-in control ID (mutually exclusive with id and idQ—specify only one of these values).

idQ

qualified id

Qualified control ID, prefixed with a namespace identifier (mutually exclusive with id and idMso—specify only one of these values).

image

String

Specifies an image for the control. (In VBA, this value is a relationship ID.)

imageMso

control id

Specifies an identifier for a built-in image, so that the Fluent UI copies the control’s icon.

insertAfterMso

control id

Specifies the identifier for the built-in control after which to position this control.

insertAfterQ

qualified id

Specifies the identifier of a qualified control (that is, a control whose idQ property was specified) after which to position this control.

insertBeforeMso

control id

Specifies the identifier for the built-in control before which to position this control.

insertBeforeQ

qualified id

Specifies the identifier of a qualified control (that is, a control whose idQ property was specified) before which to position this control.

itemSize

large, normal

For a menu, specifies the size for the items in the menu.

keytip

String

Specifies the KeyTip for this control. The KeyTip is displayed when the user presses the ALT key plus one to three letters.

label

String

Specifies the label for the control.

onAction

callback

Called when the user clicks this control.

onChange

callback

Called when the user commits text in an edit box or combo box.

screentip

String

Specifies the control’s ScreenTip.

showImage

true, false, 0, 1

Specifies whether to display the control’s image.

showItemImage

true, false, 0, 1

In a combo box, drop-down list, or gallery, specifies whether to show each item’s image.

showItemLabel

true, false, 0, 1

In a combo box, drop-down list, or gallery, specifies whether to show each item’s label.

showLabel

true, false, 0, 1

Specifies whether to show the control’s label.

size

large, normal

Specifies the size for this control.

sizeString

String

Specifies a string, such as “MMMMM”, that indicates the width for the control.

supertip

String

Specifies the Enhanced ScreenTip for the control (generally, a longer and more complete version of the ScreenTip).

tag

String

Specifies user-defined text that enables you to store information about the control that is not pertinent to any other specific property.

title

String

For a menu separator, specifies the text to be displayed (rather than a horizontal line).

visible

true, false, 0, 1

Specifies whether the control is visible.

I am looking for guidance about how to create a consistent end-user experience when customizing the Fluent UI directly with XML files or through add-ins. Can you help?

You can find the 2007 Office system guidance document UI Style Guide for Solutions and Add-Ins on the Microsoft Download Center.

Is it possible to line up (either right-justify or left-justify) text boxes in my custom Fluent UI?

No. However, you might be able to get a similar effect by using the box control. The box control is a container for other controls that has a boxStyle attribute that can be set to horizontal or vertical.

I have a document that I created from a template containing several macros. I have tried calling the macros from the Ribbon onAction callbacks without success. How can I call existing macros from Ribbon controls without modifying the original macros?

It is not possible to call macros that were created for an earlier version of Office directly from a Ribbon control without modifying the macros to include a reference to the control. However, there is a workaround. You can create a new module that contains a macro that hosts all of the Ribbon callbacks. When a call is made to the new macro from a Ribbon control, the older macro is called. The following code shows an example.

New Ribbon extensibility module

VB

Copy

Sub RibbonX_macroname(control as IRibbonControl)

   Select Case control

      button1

         macroname1

      button2

         macroname2

   End Select

End Sub

How do I get the selected index or item ID for a combo box control?

The onChange callback returns the selected string. The following code shows the signature.

VB

Copy

Sub OnChange(control as IRibbonControl, text as String)

Whenever the value of the combo box is selected, the onChange callback receives the text. However, it is not possible to get the index of the selection.

Is it possible to predict or control the order in which callbacks are called?

No. You should not add logic to your Fluent UI solutions that depends on callbacks being called in a certain order.

In an application that uses command-bar controls, the Tag property was useful for storing arbitrary strings. How can I use the IRibbonControl.Tag property in my Fluent UI solutions?

The 2007 Microsoft Office applications do not use the Tag property, so you can use it to store arbitrary strings and then retrieve them at run time. In your XML, you can set the tag as in the following code.

XML

Copy

<button id=”mybutton” tag=”some string” onAction=”MyFunction”/>

When MyFunction is called, you can get the IRibbonControl.Tag property, which will be “some string”.

Normally, you can distinguish between your controls by using the IRibbonControl.Id property, but there are restrictions on what IDs can contain (no non-alphanumeric characters, and they must all be unique). The Tag property does not have these restrictions, so it can be used in the following situations, where the Id property does not work:

If you need to store a special string with your control, such as a file name, as in this example: tag=”C:\path\to\my\file.xlsm”

If you want multiple controls to be treated the same way by your callbacks, but you do not want to have a list of all of their IDs (which have to be unique). For example, you could have buttons on different tabs all with tag=”blue”, and then just check the Tag property instead of the ID for some action in the callback.

Is it possible to display an image in a ScreenTip or Enhanced ScreenTip similar to the Chart button in the Illustrations group on the Insert tab?

No. This is not currently supported in Fluent UI extensibility.

Assume I have a custom Ribbon defined for Outlook 2007 and a different Ribbon defined for Word 2007. If I use Word for my e-mail editor, which Ribbon will I see when I create or edit an e-mail message?

When a new Inspector type is created, Outlook will call the GetCustomUI method and pass in the Ribbon ID as an argument. Even though Outlook uses Word APIs, it is still an Outlook container and uses the Outlook Ribbon.

Conclusion

The articles that make up this set provide you with the information that you need to produce professional-looking solutions that are tailored to the needs of your customers. The customization samples presented in Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3) can be used as a jumping-off point for creating a UI that places the controls and options that are most important to your customers within easy reach. The reference information described in Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3) gives you detailed control over the look and feel of the Fluent UI. This article answers many of the questions that might arise as you create your own customized Fluent UI. By applying the information presented in these articles to your own applications, you can create more innovative, attractive solutions that set you apart from your competition.

Views: 31

Hi, I’m 飞火流云

发表回复