Microsoft KB Archive/113840

{|
 * width="100%"|

XL5: Polygon with Attached Macro Changes When Fill Set to None

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 4.0, 4.0a, 5.0

-

SUMMARY
In Microsoft Excel, you can assign a macro to a graphic object so that the macro will run whenever you click the object. However, if the macro is assigned to an unfilled polygon, the macro can only be run by clicking on the border (outline) of the polygon. This is by design.

Steps to Reproduce Behavior
In version 5.0:

 Use the drawing tools to create a filled (solid) polygon on a new worksheet. (To display the drawing tools, choose Toolbars from the View menu. Select Drawing from the list of toolbars, then choose OK.)  In a Visual Basic module, enter the following macro:     Sub Message_Box MsgBox "This is a test!" End Sub  To assign the macro to the polygon, do the following:

 In the worksheet, select the polygon, and choose Assign Macro from the Tools menu. Select "Message_Box" from the list of available macros, and choose the OK button.  To turn off drawing selection mode, choose the Drawing Selection button on the Drawing toolbar. Click another cell on the worksheet so that the polygon is no longer selected.</li> Run the macro by clicking the polygon.

The "This is a test!" message box will appear.</li> Press and hold down the CTRL key and click the polygon.</li> From the Format menu, choose Object, and set Fill to None. Select OK to accept the change.</li> Click another cell on the worksheet so that the polygon is no longer selected.</li></ol>

You will no longer be able to activate the macro by clicking inside the polygon (it can only be activated by clicking the outline).

In version 4.0:

 Use the drawing tools to create a filled (solid) polygon on a new worksheet. To display the drawing tools, choose Toolbars from the Options menu. Select Drawing from the list of toolbars, then choose Show.</li>  On a new macro sheet, enter the following commands: A1: =ALERT("This is a test!")

A2: =RETURN </li> To assign the macro to the polygon:

 Select the polygon.</li> From the Macro menu, choose Assign to Object.</li> Enter a cell reference to the first cell of the macro, and choose the OK button.</li></ol> </li> Click another cell on the worksheet so that the polygon is no longer selected.</li> To run the macro, click the polygon.

The alert box will appear.</li> Press and hold down the CTRL key, and click the polygon.</li> <li>From the Format menu, choose Patterns, and set Fill to None. Select OK to accept the change.</li> <li>Click another cell on the worksheet so that the polygon is no longer selected.</li></ol>

You will no longer be able to activate the macro by clicking inside the polygon (it can only be activated by clicking the outline).