XLL+ Class Library (6.3)

SafeCode Sample

Demonstrates the use of a Structured Exception Handler to trap fatal run-time exceptions

Overview

This add-in makes use of structured exception handling, to stop Excel from crashing when unsafe code causes hardware errors such Integer Divide By Zero and Access Violation.

Any add-in that uses code from another source, which is potentially unsafe or is re-released frequently can benefit from this sort of protection.

For a fuller explanation of the technique used, see C Runtime Exceptions in the XLL+ User Guide.

Classes and functions used

CXlOper::FromDoubleArray | CXlOper::Format | CXlOper::Ret | CXlOper::RetError

Sample project

Each sample project is located in a sub-directory of the Samples directory of the XLL+ installation. To use the sample project, open the solution file SafeCode.sln or the project file SafeCode.vcproj.

You can enable debugging under Excel by using the Setup Debugging command in the XLL+ ToolWindow.

When delivered, the help files are excluded from the build. You can enable the help build by selecting the files SafeCode.help.xml and SafeCode.chm in the Solution Explorer, and using the right-click menu to view Properties. Select the page "Configuration Properties/General" and set the "Excluded from build" property to "No". See Generating help in the User Guide for more information.

See Also

List of Sample Projects | C Runtime Exceptions