From: Michelle on
I have a workbook that has a toolbar 'attached', plus some code on
BeforeClose and DeActivate which deletes/hides it.

It all works beautifully. Until...

I have a few versions of the workbook, for different purposes, and sometimes
I need to have 2 or even 3 of them open at once...

Suddenly it all goes a bit 'pear-shaped'. the toolbar now refers to the
macros in one of the books, but not necessarily the one that is active.
There are all kinds of problems such as:
Sometimes the toolbar is deleted by closing a book but there is still one of
the other books open - now with no toolbar
Sometimes clicking a button on the toolbar will cause a version of the file
that I had closed to open up again. And other associated problems.

Is there a standard way of handling this issue?
Or a clever solution that will ensure that the toolbar is always refering to
the acrtive book.

Thanks

M

From: GS on
It happens that Michelle formulated :
> I have a workbook that has a toolbar 'attached', plus some code on
> BeforeClose and DeActivate which deletes/hides it.
>
> It all works beautifully. Until...
>
> I have a few versions of the workbook, for different purposes, and sometimes
> I need to have 2 or even 3 of them open at once...
>
> Suddenly it all goes a bit 'pear-shaped'. the toolbar now refers to the
> macros in one of the books, but not necessarily the one that is active.
> There are all kinds of problems such as:
> Sometimes the toolbar is deleted by closing a book but there is still one of
> the other books open - now with no toolbar
> Sometimes clicking a button on the toolbar will cause a version of the file
> that I had closed to open up again. And other associated problems.
>
> Is there a standard way of handling this issue?
> Or a clever solution that will ensure that the toolbar is always refering to
> the acrtive book.
>
> Thanks
>
> M

Sounds to me like a perfect scenario for making an addin that's
version-aware of the different workbooks, but has one toolbar which has
menus that work on any workbook belonging to the addin. This way you
can open workbooks that have no code or toolbars attached, but require
the addin to perform automated tasks. It's considerably more involved
than using a workbook with macros!

Alternatively, you could rename the existing toolbars to include the
version so there's no conflict. (e.g.: "MyProject1", "MyProject2"...)

Also, add this to the top of your code module:

Option Private Module

so that other toolbars attached to other version workbooks can't run
another version's macros.

HTH
Garry


 | 
Pages: 1
Prev: Comparing
Next: Adding/changing registry keys