XL: How to Customize a Button on a Custom Dialog Sheet (115046)



The information in this article applies to:

  • Microsoft Excel for Windows 95
  • Microsoft Excel for Windows 5.0c
  • Microsoft Excel for the Macintosh 5.0a
  • Microsoft Excel for the Power Macintosh 5.0a

This article was previously published under Q115046

SUMMARY

In Microsoft Excel, button controls on a dialog sheet cannot be directly edited to change font properties such as font name, style, alignment, or size. However, you can indirectly modify the appearance of the button by pasting a "picture" on top of the button.

MORE INFORMATION

Customizing the Button Appearance

To customize the button appearance on a dialog sheet, follow these steps:

  1. On the File menu, click New to create a new workbook.
  2. On the Insert menu, click Macro, and then click Dialog Sheet.
  3. Click the Create Button button, and draw a button on the Dialog sheet.
  4. Erase the button's caption by selecting the text on the button and pressing the DEL key.
  5. Select a worksheet in the new workbook.
  6. In cell A1, type the following "Excel 5.0 is too cool!" (without the quotation marks).
  7. Select cell A1. On the Format menu, click Cells.
  8. Click the Font tab and select the following options:

         - For Font, select Times New Roman
         - For Size, select 8
         - For Style, select Italic.
  9. Click the Alignment tab, select the Wrap Text check box, and click OK.
  10. Press the SHIFT key, click Copy Picture on the Edit menu, and click OK.
  11. Select the dialog sheet.
  12. On the Edit menu, click Paste.
  13. Drag the pasted picture over the top of the button.
  14. Select the picture. On the Format menu, click Object.
  15. Click the Patterns tab, and select the following options, and click OK:

         - For Fill, select None
         - For Border, select none

Giving the Effect of Multiple Lines of Text

To add a button and group it with a text box to give the effect of multiple lines of formatted text, follow these steps:

  1. On a module sheet, enter the following code:

          Sub HideDialog()
             ActiveDialog.Hide
          End Sub
    						
  2. On a dialog sheet, create a button. Make it about 1.5 inches square. Clear the button text.
  3. Use the Text button on the Drawing toolbar to create a text box on top of the button. Line up its edges such that they are just inside of the button's edges.
  4. In the text box, type "Hide" and press RETURN. Then, type "the Dialog Box" so that there are two lines of text in the text box.
  5. Click the dialog box background to clear the text mode of the text box, and then click the text box again so its borders are highlighted.
  6. On the Format menu click Object, and set the following attributes for the text:

    a. Click the Patterns tab and click None under both Border and Fill.

    b. Click the Font tab. Click Times New Roman in the Font box, click Bold Italic in the Font Style box, click 18 in the Size box, and then click a color in the color box.

    c. Click the Alignment tab. Click Center in both the Horizontal and Vertical Text Alignment boxes. Click OK.
  7. Press the SHIFT key and click the edge of the button so that both the text box and button are both selected. On the Format menu, point to Placement, and click Group.
  8. With the button selected, click Assign Macro on the Tools menu. Click the HideDialog macro and click OK.
  9. Show the dialog box and click the "Hide the Dialog Box" button that you created.
The macro hides the dialog box.

Using a Graphic on a Button

To use a graphic object on top of a button, follow these steps:

  1. Add a button slightly larger than the graphic object.
  2. Paste or move the graphic object on top of the button.
  3. Press the SHIFT key and click the edge of the button so that both the graphic and the button are selected.
  4. Point to Placement on the Format menu and click Group.
  5. With the button selected, click Assign Macro on the Tools menu.
  6. Click the HideDialog macro and click OK.
  7. Display the dialog box and click the button you created.
The macro hides the dialog box.

For more information about using objects on dialog sheets, refer to Chapter 41 of the "User's Guide," version 5.0.

Modification Type:MinorLast Reviewed:8/15/2005
Keywords:kbprb kbui KB115046