Question

I've been working on a project for my team at work to use. The Excel 2003 spreadsheet is on an NT NFS so they can all use it. I like XLAs, but one annoying thing about them is it seems that they don't seem to be workbook dependent. Installing it for one installs it for the rest, and vice versa. With other languages at compile time you can easily link libraries for specific source files.

I was wondering is it possible to have workbook dependent Excel VBA custom libraries and how to do this? Thanks

Was it helpful?

Solution 2

The solution I went with was to write my own custom code for loading and unloading add-ins depending on which workbooks are opened. This was painful but it accomplished the functionality I desired perfectly. So that they could be shared by everybody, I put them on a NFS and made them read-only. When I want to change the libraries, I open them for write briefly.

OTHER TIPS

I use CustomDocumentProperties for this purpose. The add-in contains all the code and the "template" is the document to work on. In the template, create a CustomDocumentProperty called "MyApp" or whatever. In the add-in, use application level events to monitor workbook_open calls. In that event, check to see if the opened workbook contains the CustomDocumentProperty for your app. If it does, expose the UI of the add-in (like make the menus visible).

See also http://www.dailydoseofexcel.com/archives/2004/07/16/custom-document-properties/

In that example, I use the Window_Activate event. If the correct type of workbook is activate, I show the custom toolbar. If it's deactivated, I hide it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top