How to associate toolbar to a template

Y

Yi

I wanted to use VB.NET to automate Word to create a customized toolbar and
associate 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". This associates the toolbar to template
"Document1".
- Close the "Customize" dialog.

I recorded a Macro for these operations but found the Macro does not tell
how to associate 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-

Replied to duplicate question in another office.developer
group

Cindy Meister
 
H

helpasap

sub document_new
activedocument.commandbars.add "Commandbarname"
activedocument.cammandbars("CommandbarName").visible:=true
end sub

sub document_close
activedocument.commandbars("CommandbarName").delete
end sub

Jan

"Yi" schreef:
 
C

Cindy M -WordMVP-

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

You need to set the CustomizationContext, otherwise it's a
lottery in which file the toolbars will be created, and then
deleted. Look it up in the object model Help.
sub document_new
activedocument.commandbars.add "Commandbarname"
activedocument.cammandbars("CommandbarName").visible:=true
end sub

sub document_close
activedocument.commandbars("CommandbarName").delete
end sub

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