Listing illustrates how to handle its events Listing Adding a combo box control

Public Sub OnChange(ByVal control As Office.IRibbonControl, _ ByVal text As String)

Dim CurrentRange As Excel.Range = Globals.ThisAddin _ .Application.Selection

Select Case text

Case "Subscript"

CurrentRange.Font.Subscript = True Case "Superscript"

CurrentRange.Font.Superscript = True

Case "None"

CurrentRange.Font.Subscript = False CurrentRange.Font.Superscript = False End Select End Sub

The Custom group for these controls is illustrated in Figure 14.24.

Home Insert Page Layout Formulas Data Review View Custom Tab

Home Insert Page Layout Formulas Data Review View Custom Tab

Printer Setup Hide Sheetl

Attributes

1

L

Cus

Superscript

Subscript

1,

A

c

0

E

F

H

-1

*

1

7

3

4

5

6

7

8

9

10

11

17

Figure 14.24. A button, a check box, and a combo box on a Custom tab in Excel

Figure 14.24. A button, a check box, and a combo box on a Custom tab in Excel

In the next sections, you'll create a gallery, a menu, and a split button control for Word. If you're creating a new Word 2007 add-in, be sure to uncomment the code in the Ribbon1.vb code file, as shown earlier in Figure 14.9.

Gallery

A gallery is a new type of control that is available for the Ribbon. A gallery enables you to add multiple items to a single button. Galleries can be dynamic; for example, you can write code so that the gallery is dynamically populated with items, such as graphics, by reading them

0 0

Post a comment