Microsoft KB Archive/87540

= Microsoft Knowledge Base =

Excel: ASSIGN.TO.TOOL and ENABLE.TOOL Cause Macro Error
Last reviewed: July 16, 1997

Article ID: Q87540

The information in this article applies to:


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

SUMMARY
Microsoft Excel assigns a position to each tool and gap on a toolbar. In the Microsoft Excel 4.0 macro language, when you use the ENABLE.TOOL or the ASSIGN.TO.TOOL function to access a position corresponding to a gap, you receive a macro error.

MORE INFORMATION
In Microsoft Excel, the ENABLE.TOOL function allows you to enable and disable tools on toolbars. Disabled tools have the same appearance as enabled tools, but they do not respond to your actions until they are re- enabled.

The ASSIGN.TO.TOOL function produces the same results as choosing the Assign To Tool command from the Macro menu: it assigns a macro to be run when you click on a tool. For detailed information about the Assign To Tool command, see Microsoft Excel Help.

When you attempt to use these functions on a position in a toolbar that is occupied by a gap, you receive the following error message

Macro error at cell: ! where refers to the macro sheet where the function is located and specifies the cell in the macro where the command is located.

To avoid this error, use the ENABLE.TOOL function and the ASSIGN.TO.TOOL function in conjunction with the GET.TOOL function. For example, use the following line of macro code to check if the position number (5) to be enabled is a tool or a gap:

=IF(GET.TOOL(1,&quot;SampleToolbar&quot;,5)=0,,ENABLE.TOOL(&quot;SampleToolbar&quot;,5,TRUE))

If the position it is a tool, the code enables the tool (or assigns the macro), and if the position is not a tool, no action is taken.