Excel: Code Resource Does Not Execute or Unexpected Results

Last reviewed: November 29, 1994
Article ID: Q51096

SUMMARY

The information below gives possible solutions to two commonly encountered problems when using code resources with Microsoft Excel.

The Code Does Not Execute When Called from Excel

If the code does not execute when called from Excel (for example, dialog boxes don't appear as expected or devices are not polled), there may be a problem in the routine. Try compiling the routine as an application, rather than as a code resource, and running it as a stand-alone program. Once you are able to run the code stand alone, recompile it as a code resource and try calling it from Excel.

Incorrect/Unexpected Values Are Returned to Excel

If incorrect or unexpected values are returned to Excel, try compiling the routine as an application and running it stand alone. You may need to hard code values that would normally be passed from Excel. Make sure the routine returns the expected value as an application, and then recompile as a code resource.

If the value being passed back to Excel is always the same value, or is 0 (zero), and the routine returns the correct value when compiled as an application, the problem is probably due to the handling of values within the code resource. Any constants used within the code resource must be cast as their proper types (for example, short double). If any floating-point manipulations are conducted within the routine, memory address a0 must be moved to a4 at the beginning of the routine, and a4 must be returned to its previous value at the end of the routine. Return values must be declared as their own variables within the routine and not simply as one of the modified values passed to the routine.

Also check the passed and returned argument types in the REGISTER() command. The number and type of arguments passed must match those specified in the REGISTER() command, with the type passed back to Excel appearing first. The argument_types specified in the REGISTER() command must be enclosed in quotation marks.


KBCategory: kbusage
KBSubcategory:

Additional words: macrosheet 2.2 2.20 3.0 3.00 4.0 4.00


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 29, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.