View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson[_3_] Greg Wilson[_3_] is offline
external usenet poster
 
Posts: 35
Default saving toolbar buttons on custom toolbar

Hi Paul,

I actually meant for you to abandon altogether the method
of creating a toolbar and attaching it to the workbook.
Instead, just paste my code to the ThisWorkbook module.
To run my demo code, you'll have to create four dummy
macros in a standard module with the referenced macro
names. These will be called when you press the buttons.
Delete your toolbar and remove the reference from the
Attached list.

My understanding of attaching toolbars to a workbook is
that the original version of the toolbar when it was
attached is the one that is recalled upon opening the
workbook. It does not automatically update to a revised
version. You must manually unattach the toolbar, revise
it, then reattach it. My theory as to your situation is
that a version of your toolbar without buttons was
originally attached if that is possible. To resolve this,
try unattahing the toolbar, deleting it, then recreating
and reattaching.

Note that an experiment I conducted proved that even if
you delete an attached toolbar (as does your code), the
original version (when it was attached) will reappear when
the workbook is opened.

I also suggest that you NOT delete the toolbar upon close
but to make it invisible instead and also make it visible
again upon reopen using the Workbook_BeforeClose and
Workbook_Open events respectively. If my suggestions are
not successful, note that if you delete the .xlb file then
the old version will be destroyed. Of course, it will
destroy ALL toolbar customizations as well. Excel
automatically recreates the .xlb file if it has been
deleted.

The main reason I prefer the create-on-the-fly method is
because if someone saves your workbook under a different
name (using SaveAs) then all the macro references will
link to the new workbook and will no longer work for the
original version. If you have 20 or so buttons then this
is a real bitch !!! And from my experience, this will
happen a whole lot !!!

Try this experimentally but close the new workbook after
creating it. If you have created your own button images
using the button image editor then there is a way to deal
with this.

Good luck,
Greg





-----Original Message-----
Greg - thank you for the explanation and the code. In

addition to
addressing the question I asked, it was a good

illustration of using arrays
and VBA code to create a toolbar. This is going to be

helpful to me in
several areas.

Having said that, I'm surprised that if you have an

Attached toolbar, you
still need to recreate it in order to use it in the

workbook. If that't the
case, what's the point of having an attached toolbar in

the first place? Is
there anyone out there who can tell us if there's a way

to get an attached
toolbar to appear with all it's toolbar buttons on in

when you open the
workbook in which the toolbar is attached?

Thanks much.


.