Toolbar Macros

B

bw

I posted this in the Programming newsgroup, but was given a Macro solution to this
problem.

So let me post again here. I'm just looking for an explanation as to how this stuff works.

-----------------------------
I'm so confused!!!

Some history...

I have a workbook that I created maybe eight years ago, that has some simple macros
that are run ONLY from this workbook, and are accessed by clicking on Tools menu,
where the macros are listed at the bottom of the normal list. This macros (and the items
on the Tools menu) are ONLY available for this particular workbook.

I have tried to duplicate this action in two ways:
1. I have simply dragged an item from the toolbar customize box to the Tools menu, and
this works fine, but then it is present on any workbook I open from then on, and of
course, I only want it to be present for this workbook.

2. I have saved the original workbook as a new workbook, then deleted everything in
the new workbook, including one of the Tools Menu items, and reassigned new macros
to the Tools Menu items. I save this new workbook, close it, reopen it, and the Tools
menu looks just as it did without saving it.

What I want to do is create macros, assign them to a toolbar (especially if it is a Tools
menu item), and make these menu items (or toolbar buttons) available ONLY to this
workbook. I am having no luck accomplishing this.

Can anyone explain why I'm having these problems?

Thanks,
Bernie
 
D

Dave Peterson

Unless you do something special, those changes you've made to the menubar will
be available for every workbook. Just because you load them with a particular
workbook doesn't mean that they only work against that workbook. (Well, that's
the way xl97 and up work. I don't recall enough of xl95 to know how it worked.)

One way to stop them from working on a different workbook is something like this
at the top of each of your macros:

sub mymac1()
if activeworkbook.name <> thisworkbook.name then
beep
exit sub
end if
'rest of your code.

But the options still exist under the tools menu.

Anther way is to hide/delete those options when you leave this workbook. Then
show them again when you activate this workbook.

That's what Ron de Bruin's code was trying to do for you in your post in
..programming.
http://google.com/[email protected]
 
B

bw

Dave,
Ok, thanks...

I just looked at the link you povided, and see that Gord Dibben has provided the answer I
was looking for.

The macros you and Ron have provided will require me to check them out. From your
description, I guess they will provide a work around to what I currently have.

Thanks again,
Bernie
 

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