View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Stuart[_5_] Stuart[_5_] is offline
external usenet poster
 
Posts: 413
Default Two AddIn Questions

Many thanks.

In my situation, I think your solution of 'tagging' the file will
prove best-suited.

So:

The usual way to do this is the following:
1. When opening the file under addin control, the addin 'tags' the file
in some way, such as adding a custom document property or creating a
(hidden) defined name or some such.


Would you be kind enough to give a simple example, or point me
somewhere, to get started, please?

2. The addin then has a class module to hook Application-level events
and checks for SheetActivate events. Whenever a sheet is activated, the
addin checks to see if the file is 'tagged' and enables or disables its
menus appropriately.


I 'think' I can deal with the Class module code, but how to disable
(grey out?) the menu options, please? In my case, each addin has a
single entry in Excel's menubar, with a number of related dropdowns.

Could you help a little further please?

Regards and thanks.


"Stephen Bullen" wrote in message
...
Hi Stuart,

a) Can a file opened by user under Excel be checked such that:
a loaded Addin will not allow its' menu code to run on that file
(ie only run if the file opened under the addin menu)


The usual way to do this is the following:
1. When opening the file under addin control, the addin 'tags' the file
in some way, such as adding a custom document property or creating a
(hidden) defined name or some such.

2. The addin then has a class module to hook Application-level events
and checks for SheetActivate events. Whenever a sheet is activated, the
addin checks to see if the file is 'tagged' and enables or disables its
menus appropriately.

3. As an alternative to 2, the check for 'tagging' could be done in the
code for each of the addin's routines, so it wouldn't need to bother with
the enabling/disabling of menus.

b) 3 nr Addins loading, and I would prefer to keep each separate
(rather than share routines).
If I create a Class module containing Sheet_Change Event
code and declare a Public variable in that Class, for one of the
Addins, will it be visible across the Addins, and if so, how do
I limit use purely to files called by that particular Addin's menu.


Unless specifically designed and coded for, the variables will only be
available to that addin. If in point 1 above, each addin uses a
different 'tag', you'll be able to identify which addin opened which
file.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 14/07/2003