Excel: Code Resource Does Not Execute or Unexpected Results

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.

Additional query words:


Keywords          : 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: March 15, 1999