commandbar management

M

me

Hi, I am having problems with custom commandbars. In the Open event I create
a custom cb. I delete it in the BeforeClose event. If I open a second file
that has the same code before closing the first, they collide and the 2nd
one isn't created. If I then close the first, the cb is deleted so I have to
reopen the 2nd or run the code manually to create it. If I remove the code
to delete the cb beforeclose, only the first one created stays open and any
commands run run on the FIRST instance opened, even if it has been closed.
Do I have to create the cb with a unique name, such as the name of the file,
to avoid this? I'm creating many files from a single file with the code. Do
I need to implement the code in a template, or something else?

Many thanks,
Mike
 
D

Dave Peterson

If the commandbars are separate and distinct, then use unique names.

If the commandbars do the same thing, I think I would provide an addin that
built the toolbar and remove it from each of the workbooks. By separating the
code from the workbooks, it may become even easier to update when (not if)
things change.
 
M

me

Thanks Dave. That seems to make good sense, but it's uncharted territory for
me. Can you point me to a simple Add-in example, preferably with the
CommandBar implementation you're suggesting?
Cheers,
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top