Please note javascript is required for full website functionality.

Blog

A to Z of Excel Functions: The CALL Function

20 March 2017

Welcome back to our regular A to Z of Excel Functions blog.  Today we look at the CALL function.

The CALL function

Look, before we go anywhere here, this function is for advanced users only.  If you use the CALL function incorrectly, you might be looking for a new computer – well at best, you’ll have to restart your PC.  This function is only available from an Excel macro sheet in any case.  Be careful with this function!

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

So from above, the CALL function employs two different types of syntax operate.

Syntax 1:

Used with REGISTER:

CALL(register_id, [argument1],...)

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

Syntax 2:

Used alone (in Microsoft Excel for Windows):

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

The CALL function has the following arguments: 

  • module_text: this is required and is represented as quoted text specifying the name of the dynamic link library (DLL) that contains the procedure in Microsoft Excel for Windows
  • procedure: also required.  This 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
  • type_text: again, required.  This 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
  • argument1,...: optional.  These are the arguments to be passed to the procedure.

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) 

Maybe not for the faint hearted.

We’ll continue our A to Z of Excel Functions soon.  Keep checking back – there’s a new blog post every other business day.

Newsletter