How to assign toolbar to a template

Y

Yi

I wanted to use VB.NET to automate Word to create a customized toolbar and
assign the toolbar to a certain template, so that only when opening a file
created based on this template, this customized toolbar will be displayed.

I did the following manually using Office XP:
- Select menu item "tools/customize", "toolbars" tab. Press button "New".
- In the "New Toolbar" dialog, list "Make toolbar available to", select one
item, e.g. "Document1". Press "OK".
- Close the "Customize" dialog.

I recorded a Macro for these operations but found the Macro does not tell
how to assign the toolbar to the template. The Macro contains only one
command "CommandBars.Add(Name:="Custom 1").Visible = True".

Is there a method to do the same operation with VB code? Or is there other
way to display a customized toolbar only to a group of documents that are
created with a certain template?

Best wishs,
Yi
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?WWk=?=,

Look up CommandBars in the VBA Help files, as well as on MSDN so that you can
see how the object and its properties and methods are used.

To tell VBA to store the CommandBar you're creating in a specific Word
document, you need to set the CustomizationContext before you start building
the CommandBar.
I wanted to use VB.NET to automate Word to create a customized toolbar and
assign the toolbar to a certain template, so that only when opening a file
created based on this template, this customized toolbar will be displayed.

I did the following manually using Office XP:
- Select menu item "tools/customize", "toolbars" tab. Press button "New".
- In the "New Toolbar" dialog, list "Make toolbar available to", select one
item, e.g. "Document1". Press "OK".
- Close the "Customize" dialog.

I recorded a Macro for these operations but found the Macro does not tell
how to assign the toolbar to the template. The Macro contains only one
command "CommandBars.Add(Name:="Custom 1").Visible = True".

Is there a method to do the same operation with VB code? Or is there other
way to display a customized toolbar only to a group of documents that are
created with a certain template?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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