Re: Ensuring the Style control is visible in the toolbars in our embedded Word?



Hi Brian,

However, the Word toolbars seem to come up based on the particular User's
usage of Word... or some other pattern I haven't identified. It would be
nice if I could tell Word to make sure that the style control is visible in
the toolbars, but still otherwise let the Toolbars behave "normally".

Yes, Word saves the user's customizations to the toolbars.

Toolbars are controlled through the CommandBars collection of the Office
object model. In Word, toolbars can be set globally, by template, or by
document. So when you work with a toolbar it's important to set the
CustomizationContext. If customizing a toolbar for just one document, then

application.CustomizationContext = ActiveDocument

Programmatically, the way to approach this would be to get the CommandBar in
question (Dim cb as Office.CommandBar =
Application.CommandBars("Formatting")). Loop through the available controls on
the commandbar and test either the ID or the caption to get the button. If
it's there, check that the .Visible and .Enabled properties are true. If it's
not there, ADD it back on.

I've never investigated how Word's commandbar management "translates" into an
embedded OLE control such as you're using. If things work "normally", then you
should be able to include the toolbar customization as part of the XML
document. Either store the "template" with the customization already in it. OR
put it in with a transform.

In order to "save" this difference in the document, you'd need to remove the
control in question from the Normal.dot template (customization context), then
add it back in, saving the change in the document, itself.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :-)

.