Microsoft KB Archive/115046

= XL: How to Customize a Button on a Custom Dialog Sheet =

Article ID: 115046

Article Last Modified on 8/15/2005

-

APPLIES TO


 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0c
 * Microsoft Excel 5.0a for Macintosh
 * Microsoft Excel 5.0a for Macintosh

-



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.



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

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

<pre class="fixed_text">    - For Font, select Times New Roman - For Size, select 8 - For Style, select Italic. </li> Click the Alignment tab, select the Wrap Text check box, and click OK.</li> Press the SHIFT key, click Copy Picture on the Edit menu, and click OK.</li> Select the dialog sheet.</li> On the Edit menu, click Paste.</li> Drag the pasted picture over the top of the button.</li> Select the picture. On the Format menu, click Object.</li>  Click the Patterns tab, and select the following options, and click OK:

<pre class="fixed_text">    - For Fill, select None - For Border, select none </li></ol>

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:

<ol>  On a module sheet, enter the following code:

Sub HideDialog ActiveDialog.Hide End Sub </li> On a dialog sheet, create a button. Make it about 1.5 inches square. Clear the button text.</li> 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.</li> 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.</li> 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.</li> 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.</li> 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.</li> <li>With the button selected, click Assign Macro on the Tools menu. Click the HideDialog macro and click OK.</li> <li>Show the dialog box and click the "Hide the Dialog Box" button that you created.</li></ol>

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.

Keywords: kbui kbprb KB115046

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.