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.
MORE INFORMATION
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:
a. In the worksheet, select the polygon, and choose Assign Macro from
the Tools menu.
b. 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.
- Run the macro by clicking the polygon.
The "This is a test!" message box will appear.
- Press and hold down the CTRL key and click the polygon.
- From the Format menu, choose Object, and set Fill to None. Select OK to
accept the change.
- Click another cell on the worksheet so that the polygon is no longer
selected.
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.
- On a new macro sheet, enter the following commands:
A1: =ALERT("This is a test!")
A2: =RETURN()
- To assign the macro to the polygon:
a. Select the polygon.
b. From the Macro menu, choose Assign to Object.
c. Enter a cell reference to the first cell of the macro, and choose the
OK button.
- Click another cell on the worksheet so that the polygon is no longer
selected.
- To run the macro, click the polygon.
The alert box will appear.
- Press and hold down the CTRL key, and click the polygon.
- From the Format menu, choose Patterns, and set Fill to None. Select OK
to accept the change.
- Click another cell on the worksheet so that the polygon is no longer
selected.
You will no longer be able to activate the macro by clicking inside the
polygon (it can only be activated by clicking the outline).
REFERENCES
"User's Guide," version 5.0, pages 230, 637
"User's Guide 1," version 4.0, page 509
|