Microsoft KB Archive/95890

= xlcOpen Function Should Not Be Used in Function Macro =

Article ID: 95890

Article Last Modified on 9/25/2003

-

APPLIES TO


 * Microsoft Excel Software Development Kit 4.0

-



This article was previously published under Q95890



SUMMARY
The xlcOpen function should not be used in a dynamic-link library (DLL) function registered as a function macro. This function requires approximately 11,800 bytes of stack space to operate. Rarely will this much space be available on the Microsoft Excel stack when a DLL function registered as a function macro is called.

The exact amount of stack space required to open a file varies with the type of file. Worksheets containing embedded charts require more stack space than other files. If xlcOpen is called with insufficient stack space, the result usually is a general protection (GP) fault in Microsoft Excel.



MORE INFORMATION
The following implementation methods are recommended in cases where xlcOpen functionality is required:  Use the macro function OPEN instead. Use a macro to open files as needed, then call the necessary DLL functions. Note that calling a macro function containing OPEN from a DLL won't work properly, because this requires more stack space than calling xlcOpen alone. Use xlcOpen in a DLL function registered as a command macro. DLL functions registered as command macros (Macro_type 2) have approximately 1000 bytes less stack overhead. Consequently, top-level command macro DLL functions generally have enough free stack space to call xlcOpen.  If xlcOpen must be used, always call xlStack first to check stack space: #define STACKMIN_XLCOPEN 11800

Excel4(xlStack,&xlResult,0);

if (xlStack.val.w < STACKMIN_XLCOPEN) {        ErrorHandler; }     else {        Excel4(xlcOpen,&xlResult,(LPXLOPER) xlFile); }                       

Additional query words: 4.00 GPF crash GP-fault

Keywords: KB95890

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.