Excel

Framework library function. This is a wrapper for the Excel4 function. It checks to see that none of the arguments is zero, which would indicate that a temporary XLOPER failed. If an error occurs, it prints a debug message. When finished, it frees all temporary memory.

Returns one of the following (int).

Value

Return code

Description

0

xlretSuccess

The function was called successfully. This does not mean that the function did not return a Microsoft Excel error value; to find that out, you have to look at the resulting XLOPER.

1

xlretAbort

An abort occurred (internal abort). You might get this if a macro closes its own macro sheet by calling CLOSE, or if Microsoft Excel is out of memory. In this case you must exit immediately. The DLL can call only xlFree before it exits. The user will be able to save any work interactively using the Save command on the File menu.

2

xlretInvXlfn

An invalid function number was supplied. If you are using constants from XLCALL.H, this shouldn't happen.


Value

Return code

Description

4

xlretInvCount

An invalid number of arguments was entered. Remember that no Microsoft Excel function can take more than 30 arguments, and some require a fixed number of arguments.

8

xlretInvXloper

An invalid XLOPER structure or an argument of the wrong type was used.

16

xlretStackOvfl

(Windows only) A stack overflow occurred. Use xlStack to monitor the amount of room left on the stack. If possible, avoid allocating large local (automatic) arrays on the stack ; make them static. (Note that a stack overflow may occur without being detected.)

32

xlretFailed

A command-equivalent function failed. This is equivalent to a macro command displaying the macro error alert dialog box.

64

xlretUncalced

An attempt was made to dereference a cell that has not been calculated yet, because it was scheduled to be recalculated after the current cell. In this case the DLL needs to exit immediately. It can call only xlFree before it exits. For more information, see "Dealing with Uncalculated Cells" on page 196.


Syntax

Excel(int iFunction, LPXLOPER pxRes, int iCount, 
LPXLOPER argument1, ...)

iFunction (int)

A number indicating the command, function, or special function you want to call. For a list of valid iFunction values and related information, see the "Remarks" section under "Excel4" on page 215.

pxRes (LPXLOPER)

A pointer to an allocated XLOPER (10 bytes) that will hold the result of the evaluated function.

iCount (int)

The number of arguments that will be passed to the function.

argument1, ... (LPXLOPER)

The optional arguments to the function. All arguments must be pointers to XLOPERs.

Example

This example passes a bad argument to the Excel function, which sends a message to the debugging terminal.

\SAMPLES\EXAMPLE\EXAMPLE.C

short WINAPI ExcelExample(void)
{
    Excel(xlcDisplay, 0, 1, 0);
    return 1;
}

Related Function

Excel4