Microsoft KB Archive/51089

{| = Excel: Calling a Code Resource Using CALL/REGISTER Routines =
 * width="100%"|

Last reviewed: April 3, 1997

Article ID: Q51089 2.20 MACINTOSH The information in this article applies to:


 * Microsoft Excel for the Macintosh, version 2.2

SUMMARY
Microsoft Excel can call routines that have been compiled as code resources (sometimes referred to as dynamic link libraries, or DLLs).

Code resources are called from macros and operate much like function macros.

Before a resource can be called, it must first be registered to Microsoft Excel using the REGISTER command. The REGISTER command loads the code resource into memory and defines the parameters that the resource will accept and return.

REGISTER Command
The following is the format of the REGISTER command:

REGISTER(file_name,resource_name,argument_types) &quot;file_name&quot; is the name of the file containing the code resource. Microsoft Excel looks in the active directory for the file containing the code resource, unless a pathname is specified. &quot;resource_name&quot; is the name given to the code resource when it is compiled. You must always specify a resource name, even if there is only one code resource in the file.

&quot;argument_types&quot; is a text string specifying the argument type passed to Microsoft Excel and the argument types passed from Microsoft Excel to the code resource. Note that the first character specifies the argument passed from the resource to Microsoft Excel, and the subsequent characters specify the arguments passed from Microsoft Excel to the code resource.

When the resource is successfully registered, the value of the cell containing the REGISTER command is a text string that is used by the CALL command. A registered command can be called multiple times.

Once registered, the code resource is called using the CALL command.

CALL Command
The following is the format of the CALL command:

CALL(call_text,argument1,argument2,...) &quot;call_text&quot; is the value returned by the REGISTER command. It is almost always a reference to the cell containing the REGISTER command. &quot;argument1,argument2,...&quot; is a list of up to 13 arguments passed from Excel to the code resource. These arguments must match in number and type the arguments specified in the REGISTER command. For buffers passed to the resource, a comma is used with no argument.

When the resource is no longer used, it should be unregistered using the UNREGISTER command to free memory taken by the resource.

UNREGISTER Command
The following is the format of the UNREGISTER command:

UNREGISTER(call_text) &quot;call_text&quot; is the value returned by the REGISTER command and is almost always a reference to the cell containing the REGISTER command. For more information on calling code resources from Excel, query on the following words:

description and creating and code and resource and call and register and routine and problems and floating and point and decimal

MORE INFORMATION
For more information on the CALL, REGISTER, and UNREGISTER commands, see pages 201, 266-267, and 289, respectively, in the &quot;Microsoft Excel Functions and Macros&quot; version 2.2 manual.

Additional information can be found in the &quot;Microsoft Excel Technical Reference for the Macintosh,&quot; which is available as part of the Microsoft Excel Development Kit. To obtain this kit, call Microsoft End User Sales and Services at (800) 426-9400.
 * }