MS Office Forum / Word / Programming / March 2008
Share Toolbar for multiple templates
|
|
Thread rating:  |
mamue - 03 Mar 2008 10:59 GMT Hi,
is it possible to share a toolbar to use it within multiple templates? I've put the template with the toolbar to be shared in the office startup folder, but i want the toolbar to appear only in specific templates, not in everyone.
cheers, matthias
Graham Mayor - 03 Mar 2008 11:34 GMT You could remove it to the specific templates?
 Signature <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP
My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Hi, > [quoted text clipped - 4 lines] > > cheers, matthias mamue - 03 Mar 2008 12:17 GMT > You could remove it to the specific templates? > [quoted text clipped - 14 lines] > > > cheers, matthias Sorry Graham, i didn't understand what you mean with "removing to specific templates".
cheers, matthias
Graham Mayor - 03 Mar 2008 14:09 GMT Currently you have the toolbar in a global template, which by implication will make it available to all documents. if you only want it applicable only to certain document templates, then copy it to those templates (using the organizer) and remove it from the global template. If buttons on the toolbar call macros stored elsewhere, you will probably have to re-add the macro buttons to the toolbars after you have moved them.
 Signature <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP
My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> You could remove it to the specific templates? >> [quoted text clipped - 19 lines] > > cheers, matthias Jean-Guy Marcil - 03 Mar 2008 14:00 GMT > Hi, > > is it possible to share a toolbar to use it within multiple templates? > I've put the template with the toolbar to be shared in the office > startup folder, but i want the toolbar to appear only in specific > templates, not in everyone. For this to truely work, you will need application events. You need to detect when a document is created/opened, then you need to check the attached template, if it belongs to your list, display the toolbar, otherwise hide it. Then, becasue a user may work with many documents at once, all based, maybe, on different templates, you also need to detect when the user changes from document to document and display/hide the toolbar as appropriate. I have done something like this in the past and I can assure you that it is not trivial. For someone who has experience with VBA and Application events, it is not difficult, but it does take some time as a fair amount of code has to be written and checked.
If you are a VBA beginner, this is quite a challenge! In any case, since you need to go through Application Events, you may want to find out about them, start here: http://word.mvps.org/faqs/macrosvba/AppClassEvents.htm
mamue - 03 Mar 2008 14:13 GMT On Mar 3, 3:00 pm, Jean-Guy Marcil <JeanGuyMar...@discussions.microsoft.com> wrote:
> > Hi, > [quoted text clipped - 18 lines] > start here: > http://word.mvps.org/faqs/macrosvba/AppClassEvents.htm Thanks Jean-Guy, i'll check that page, altough i hope for a more trivial way ;-)
Jean-Guy Marcil - 03 Mar 2008 17:05 GMT > Thanks Jean-Guy, i'll check that page, altough i hope for a more > trivial way ;-) If you want an easy/trivial way, I believe that Graham's suggestions fits the bill. One minor drawback is that you will have to maintain multiple instances of the same code. One major drawback is that if a user works on two documents, each one being based on two different templates, there will two instances of the toolbar on the UI. If you have 5 different templates, you could end up with 5 instances of the toolbar on the UI...
Jonathan West - 04 Mar 2008 10:13 GMT > Hi, > [quoted text clipped - 4 lines] > > cheers, matthias Hi Matthias
Both Graham and Jean-Guy have given you parts of the answer, but they have complicated things a bit.
Proceed as follows:
For each template whose documents you want to display to the toolbar, copy the toolbar from your global template to the document template.
When you have done this, delete the toolbar from your global template.
The toolbar will now only be visible when a document based on one of those individual templates is active. The buttons will work as normal, provided that the global template is loaded as an add-in. The best way to do that is for the global template to be put in the startup folder so it is loaded when Word is started.
That really is all there is to it.
You can then if you wish customise the toolbar for each individual template, removing buttons that aren't needed for that document type.
 Signature Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup
Jean-Guy Marcil - 04 Mar 2008 13:16 GMT > Proceed as follows: > [quoted text clipped - 10 lines] > > That really is all there is to it. Hi Jonathan,
I'll be... !!! I have tried something like this in the past and I seem to remember that I had a problem regarding the multiple appearance of the toolbar according to the number of active attached templates. I guess I must have done someting different from what you outlined... Maybe my overly-cautious nature made me name each toolbar differently... This must be why your approach does not have this problem... All toolbars have the same name, right? If not, why is it that even if you have 3 active attached templates you still get only one instance of the toolbar?
Thanks... again!
Jean-Guy Marcil - 04 Mar 2008 15:00 GMT > overly-cautious nature made me name each toolbar differently... This must be > why your approach does not have this problem... All toolbars have the same > name, right? If not, why is it that even if you have 3 active attached > templates you still get only one instance of the toolbar? Never mind... I must have gone to bed too late last night! As long as you do not have three template in the global folder, each document has only one attached template, so of course, only one toolbar will be displayed at the time...
I think that I am confusing issues here becasue I had a project where I had to use a few global templates... Hence the problem I had with the many toolbars... I can't remember the specifics... It was a few years ago... (Or it may have been another project where the toolbar had to be diffrent depending on the type of document, but the client wanted only one template... So I needed Application events to check the type of document being displayed and modify the toolbar on the fly...)
That'll teach me to try to help somebody based on a hazy recollection!
Thanks for your input!
Jonathan West - 04 Mar 2008 21:21 GMT >> overly-cautious nature made me name each toolbar differently... This must >> be [quoted text clipped - 24 lines] > > Thanks for your input! This is the standard way I proceed these days for my commercial templates. I have a lot of VBA code for them, and it makes sense to have it included in the overall project only once, and have the individual templates use the bits they need from a customized toolbar in the document template which calls code in the add-in.
 Signature Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup
mamue - 05 Mar 2008 08:27 GMT > >> overly-cautious nature made me name each toolbar differently... This must > >> be [quoted text clipped - 35 lines] > Jonathan West - Word MVPwww.intelligentdocuments.co.uk > Please reply to the newsgroup Thanks to all of you. The willingness to help in this group is amazing. I copied the toolbar Jonathan's way. And it works ;-)
|
|
|