XLL+ Class Library (7.0)

Publish Opt-Out Demo Sample - PubDevOut

Applies a function filter with an Opt-Out policy

Remarks

This project demonstrates how to use a function filter to restrict which add-in functions are made available to users. The project applies an Opt-Out policy, so that only add-in functions whose FunctionFilterOptOut property is specifically marked as True will be hidden from to users.

The add-in functions included in the sample fall into 3 groups:

  1. ReadyFn & ReadyFn2 are marked as FunctionFilterOptIn = True
  2. NotReadyFn & NotReadyFn2 are marked as FunctionFilterOptOut = True
  3. OtherFn & OtherFn2 are not marked

Because a function filter is being applied, ReadyFn & ReadyFn2 will be published, but NotReadyFn & NotReadyFn2 will not. Because it is an opt-out filter, OtherFn & OtherFn2, which are not marked, will be published.

The only code added to the sample to achieve the filtering is the following:

CopyC++
#ifndef _DEBUG
CXllFunctionFilterEventHandlerOptOut theFunctionFilter;
#endif

This code declares a static global instance of CXllFunctionFilterEventHandlerOptOut, which automatically runs the filtering code just before add-in functions are registered with Excel. As a result, any function that is marked as FunctionFilterOptOut = True will be suppressed.

Note that the code is surrounded by a #ifndef _DEBUG ... #endif block, so that the filter only applies to the Release build. This means that in the Debug build, the developer can continue to work with the functions that are filtered out.

For a discussion of function filtering, see the User Guide topic Publishing and suppressing add-in functions.

Requirements

To edit the functions in this add-in, you need to load the extension file FunctionFilter.xpe which is located in the extensions directory of your XLL+ installation. See Loading an extension file for instructions.

Classes and functions used

CXllFunctionFilter | CXllFunctionFilterEventHandlerOptOut

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 PubDevOut.sln or the project file PubDevOut.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 PubDevOut.help.xml and PubDevOut.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 | Publish Opt-In Demo | Publish Run-time Demo | Publishing and suppressing add-in functions (User Guide)