Last modified: March 18, 2009

Applies to: Excel 2010 | Office 2010 | VBA | Visual Studio

Returns information about the cell, range of cells, command on a menu, tool on a toolbar, or object that called the DLL command or function that is currently running.

Code called from



The Register ID.

A single cell

A single-cell reference.

A multi-cell array formula

A multi-cell reference.

A conditional formatting expression

A reference to the cell to which the formatting condition is applied.

A menu

A four-element single-row array:

  • The bar ID.

  • The menu position.

  • The submenu position.

  • The command position.

A toolbar

A two-element single-row array:

  • The toolbar number for built-in toolbars or the toolbar name for custom toolbars.

  • The position on the toolbar.

A graphic object

The object identifier (object name).

A command associated with an xlcOnEnter, ON.ENTER, event trap

A reference to the cell or cells being entered.

A command associated with an xlcOnDoubleclick, ON.DOUBLECLICK, event trap.

The cell that was double-clicked (not necessarily the active cell).

Auto_Open, AutoClose, Auto_Activate or Auto_Deactivate macro

The name of the calling sheet.

Other methods not listed

#REF! Error.

Excel12(xlfCaller, (LPXLOPER12) pxRes,0);

The return value is one of the following XLOPER/XLOPER12 data types: xltypeRef, xltypeSRef, xltypeNum, xltypeStr, xltypeErr, or xltypeMulti. Since three of these types point to allocated memory, the return value of xlfCaller should always be freed in a call to the xlFree function when it is no longer needed.

For more information about XLOPERs/XLOPER12s see Memory Management in Excel.

This function is the only non-worksheet function that can be called from a DLL/XLL worksheet function. Other XLM information functions can only be called from commands or macro-sheet equivalent functions.

\SAMPLES\EXAMPLE\EXAMPLE.C. This function calls a command macro (xlcSelect) and will work correctly only when called from a macro sheet.

short WINAPI CallerExample(void)
   XLOPER12 xRes;

   Excel12(xlfCaller, &xRes, 0);
   Excel12(xlcSelect, 0, 1, (LPXLOPER12)&xRes);
   Excel12(xlFree, 0, 1, (LPXLOPER12)&xRes);
   return 1;