Automatically hiding a button on a toolbar when a template opens.

C

Colinhp

What is the Visual Basic code to hide a specific button on a toolbar when a
new document is loaded from a template?
 
D

Default User

Following routine in ThisDocument classmodule will do the trick, whereby X
is the number/name of the target 'toolbar'

Private Sub Document_New()
CustomizationContext = ActiveDocument.AttachedTemplate
CommandBars(X).Visible = False
End Sub
Note:
1) you can affect and confuse the user experience by hiding familiar
toolbars...
2) toolbars are part of the commandbars collection
3) restrict the scope to documents based on this template, using the
CustomizationContext clause

Below URL's will get you more info on the above topics
Krgrds,
Perry

http://msdn.microsoft.com/library/d...tml/woproCustomizationContext1_HV05210405.asp
http://msdn.microsoft.com/library/d...us/off2000/html/woproCustomizationContext.asp

http://msdn.microsoft.com/library/d.../vbaof11/html/ofproCommandBars_HV03083171.asp
and
http://msdn.microsoft.com/library/d.../vbaof11/html/ofproCommandBars_HV03083171.asp
 

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