CALL

Microsoft Office Excel 2003

See Also

Caution   Incorrectly editing the registry may severely damage your operating system, requiring you to reinstall it. Microsoft cannot guarantee that problems resulting from editing the registry incorrectly can be resolved. Before editing the registry, back up any valuable data. For the most recent information about using and protecting your computer's registry, see Microsoft Windows Help.

Calls a procedure in a dynamic link library or code resource. There are two syntax forms of this function. Use syntax 1 only with a previously registered code resource, which uses arguments from the REGISTER function. Use syntax 2a or 2b to simultaneously register and call a code resource.

Important  This function is provided for advanced users only. If you use the CALL function incorrectly, you may cause errors that will require you to restart your computer. This function is only available from an Excel macro sheet.

Syntax 1

Used with REGISTER

CALL(register_id,argument1,...)

Syntax 2a

Used alone (in Microsoft Excel for Windows)

CALL(module_text,procedure,type_text,argument1,...)

Syntax 2b

Used alone (in Microsoft Excel for the Macintosh)

CALL(file_text,resource,type_text,argument1,...)

Register_id    is the value returned by a previously executed REGISTER or REGISTER.ID function.

Argument1, ...    are the arguments to be passed to the procedure.

Module_text    is quoted text specifying the name of the dynamic link library (DLL) that contains the procedure in Microsoft Excel for Windows.

File_text    is the name of the file that contains the code resource in Microsoft Excel for the Macintosh.

Procedure    is text specifying the name of the function in the DLL in Microsoft Excel for Windows. You can also use the ordinal value of the function from the EXPORTS statement in the module-definition file (.DEF). The ordinal value must not be in the form of text.

Resource    is the name of the code resource in Microsoft Excel for the Macintosh. You can also use the resource ID number. The resource ID number must not be in the form of text.

Type_text    is text specifying the data type of the return value and the data types of all arguments to the DLL or code resource. The first letter of type_text specifies the return value. The codes you use for type_text are described in detail in Using the CALL and REGISTER Functions. For stand-alone DLLs or code resources (XLLs), you can omit this argument.

Example

Syntax 1 (32-Bit Microsoft Excel)

IN 32-bit Microsoft Excel for Windows, the following macro formula registers the GetTickCount function from 32-bit Microsoft Windows. GetTickCount returns the number of milliseconds that have elapsed since Microsoft Windows was started.

REGISTER("Kernel32","GetTickCount","J")
		

Assuming that this REGISTER function is in cell A5, after your macro registers GetTickCount, you can use the CALL function to return the number of milliseconds that have elapsed:

CALL(A5)
		

Syntax 1 (16-Bit Microsoft Excel)

In 16-bit Microsoft Excel for Windows, the following macro formula registers the GetTickCount function from 16-bit Microsoft Windows. GetTickCount returns the number of milliseconds that have elapsed since Microsoft Windows was started.

REGISTER("User","GetTickCount","J")
		

Assuming that this REGISTER function is in cell A5, after your macro registers GetTickCount, you can use the CALL function to return the number of milliseconds that have elapsed:

CALL(A5)
		

Example

Syntax 2a (32-Bit Microsoft Excel)

On a worksheet, you can use the following CALL formula (syntax 2a) to call the GetTickCount function:

CALL("Kernel32","GetTickCount","J!")
		

The ! in the type_text argument forces Microsoft Excel to recalculate the CALL function every time the worksheet recalculates. This updates the elapsed time whenever the worksheet recalculates.

Syntax 2a (16-Bit Microsoft Excel)

On a worksheet, you can use the following CALL formula (syntax 2a) to call the GetTickCount function:

CALL("User","GetTickCount","J!")
		

The ! in the type_text argument forces Microsoft Excel to recalculate the CALL function every time the worksheet recalculates. This updates the elapsed time whenever the worksheet recalculates.

ShowTip

You can use optional arguments to the REGISTER function to assign a custom name to a function. This name will appear in the Insert Function dialog box, and you can call the function by using its custom name in a formula. For more information, see REGISTER.