XLL+ Class Library

Using ComWrapperGen on the command-line

The utility can be run from the command line, or from a batch file, using the command line parameters discussed below.

Usage

COMWRAPPERGEN [options]

If no options are supplied, then the generator will run interactively (see Using the wrapper generator).

Options

The command line options are listed below. Note that Source file (-s), Project name (-p), Class name (-c) and Destination folder (-d) are all required arguments.

Option Description
-s (required) Source file. The C++ source file containing the Excel add-in methods to be exported. This option can be used more than once, to include multiple source files.
-p (required) Project name. This will be used as the name of the VB project, and (by default) as the name of the COM library.
-c (required) Class name. This will be used as the name of the COM object class. It is normally the name of the XLL (without the ".xll" extension). If it is not the name of the XLL, then you will need to change the code in the GetAddins event handler.
-d (required) Destination directory. The directory where the VB project files will be written. If the directory does not exist (but its parent does), the generator will create it.
-e Excel error type handler. Controls whether the generated COM methods will throw an error if an Excel error type (e.g. #N/A) is returned by the wrapped add-in function. The option should be followed by either True or False. If omitted, False is assumed. See Error handling for more details.
-x String error prefix. Controls whether the generated COM methods will throw an error if a string with the supplied prefix is returned by the wrapped add-in function. If omitted, no such errors will be thrown. See Error handling for more details.
-m Implementation model. Controls which implementation model will be used to host the add-in functions. Currently only the following models are supported: EA (Excel Application) and XD (XLL Host). If omitted, the model EA will be assumed. See ExcelWrapper class for more details.
-q Quiet option. Controls whether a message box is displayed after completion. The option should be followed by either True (no message box is displayed) or False (message box is displayed). If omitted, False is assumed.

Examples

COMWRAPPERGEN -s C:\Files\simpopt.cpp -p SimpOptLib -c SimpOpt -d C:\Files\SimpOptWrapper -e True -x "#ERROR:" -m AE

The generator will create a library SimpOptLib.dll containing an object class SimpOpt which exports all the add-in functions found in simpopt.cpp.

Functions that return Excel error values (e.g. #N/A) will raise a COM error at run-time. If a function returns a string result that begins with #ERROR: a COM error will be raised at run-time.

The standard EA implementation model (using an Excel Application) will be used.

COMWRAPPERGEN -s C:\Files\simpopt.cpp -s C:\Files\avgopt.cpp -p OptionLib -c OptionCalc -d C:\Files\OptionLib -e True -x "#ERROR:" -m XD

The generator will create a library OptionLib.dll containing an object class OptionCalc which exports all the add-in functions found in simpopt.cpp and in avgopt.cpp.

Functions that return Excel error values (e.g. #N/A will raise a COM error at run-time. If a function returns a string result that begins with #ERROR: a COM error will be raised at run-time.

The XD implementation model (using the Xll Host) will be used.

See Also

XLL+ COM wrapper generator | Using the wrapper generator