XLL+ Class Library (6.3)

StringHandleDemo Sample

Demonstrates the use of string handles to represent objects in Excel

Overview

This add-in contains code very similar to that described in the User Guide topic Using object handles. The difference is that it uses string handles instead.

String handles (as implemented in the StringHandles.xpe extension) consist of the object's name followed by its index within the list of all active handles. This is the easiest handle type for a user to "debug", since the numbers are manageably short, unlike the pointers which are used by the NumericHandles.xpe and StringPtrHandles.xpe extensions. However, this type of handle is slightly less robust than the other two styles, since it is possible for a handle which has been erroneously changed from a formula to a value to remain a valid - but misleading - handle value.

Requirements

To edit the functions in this add-in, you need to load the extension file StringHandles.xpe. See Loading an extension file for instructions.

You should also make sure that neither of the following extension files is loaded, since the various types of handles are mutually exclusive.

Changing handle type

The add-in functions in this sample were copied from the NumericHandleDemo sample. The following steps are required to change the handle type from numeric to string:

  1. Using the Tool/Options/XLL+/Extensions page, unload NumericHandles.xpe and load StringHandles.xpe.
  2. In the XLL Add-ins window, select all the add-in functions in the source file, and click the Regenerate functions command. All the handle code will be regenerated, and some argument types will be changed from numeric to string.
  3. At the top of the source file, remove the line: #include "extensions\NumericHandles.h".

The project can then immediately be rebuilt and run.

Classes and functions used

CXlOper::operator = | CXlOper::Ret

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 StringHandleDemo.sln or the project file StringHandleDemo.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 StringHandleDemo.help.xml and StringHandleDemo.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 | Using object handles | RtdHandleDemo sample | NumericHandleDemo sample | StringPtrHandleDemo sample