Add-in Manager

You can always load an xll using File>Open... which then calls xlAutoOpen, but Excel has a mechanism for loading an xll every time you run it. In Excel 2003 and earlier Tools>Add-Ins... will get you to the Add-in Manager dialog. In 2007 and later File>Options, then Add-Ins and Manage: Excel Add-ins and pressing Go... brings it up.

You can Browse... for the location of your add-in and when you click OK
xlAutoAdd then xlAutoOpen are called. Deselecting an add-in calls xlAutoRemove then xlAutoClose.

The xll library provides hooks for calling any code you please from any of the xlAutoXXX events. Just write a function, e.g., int xll_foo(void) that returns 1 on success and 0 if things go pear shaped then create a static Auto<XXX> xao_foo(xll_foo) object and Robert is your father’s brother. Multiple instantiations add functions to the list.

The xll library implementation calls a function to register all the AddIn objects in xlAutoOpen and Auto<Open> functions get executed before that. If you need to call something after the functions are registered you can use Auto<OpenAfter>. Likewise, xlAutoRemove unregisters the AddIn objects. If you need call something before the functions are unregistered you can use Auto<RemoveBefore>.

The gory details can be found in: auto.cpp.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s