This function uses the Microsoft Excel parser and function evaluator to evaluate any expression that could be entered in a worksheet cell.
Returns the result of evaluating the string.
Excel4(xlfEvaluate, LPXLOPER pxRes, 1, LPXLOPER pxFormulaText)
pxFormulaText (xltypeStr)
The string to evaluate, optionally beginning with an equal sign (=).
The string can contain only functions, not command equivalents. It is equivalent to pressing F9 from the formula bar.
The primary use of the EVALUATE function is to allow DLLs to find out the value assigned to a defined name on a sheet.
EVALUATE cannot be used to evaluate references to an external sheet that is not open.
The following example takes a text value, a5, and jumps to the location it represents by using the EVALUATE function.
This example uses xlfEvaluate to coerce the text "B38" to the contents of cell B38.
\SAMPLES\EXAMPLE\EXAMPLE.C
short int WINAPI EvaluateExample(void)
{
XLOPER xFormulaText, xRes, xRes2, xInt;
xFormulaText.xltype = xltypeStr;
xFormulaText.val.str = "\004!B38";
Excel4(xlfEvaluate, (LPXLOPER)&xRes, 1, (LPXLOPER)&xFormulaText);
xInt.xltype = xltypeInt;
xInt.val.w = 2;
Excel4(xlcAlert, (LPXLOPER)&xRes2, 2, (LPXLOPER)&xRes,
(LPXLOPER)&xInt);
Excel4(xlFree, 0, 1, (LPXLOPER)&xRes);
Excel4(xlFree, 0, 1, (LPXLOPER)&xRes2);
return 1;
}