xlcOpen() Function Should Not Be Used in Function Macro

ID: Q95890


The information in this article applies to:
  • Microsoft Excel Software Development Kit, version 4.0


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 :
Version : :4.0
Platform :
Issue type :


Last Reviewed: November 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.