Welcome toWord.Tips.Net
Ask a Word Question
Make a Comment
Learn Access Now
Free Printable Forms
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips
Collapsing and Expanding Subdocuments
There are certain toolbar buttons that when you press them, they change to have a different appearance. For instance, if you press on the Bold tool, the tool takes on a different look, as if it is depressed. This is done by Word by using two different button graphics. The first is the "unselected" appearance, and the other is displayed when the button has been clicked.
You can use a similar trick with your custom toolbar buttons. As an example of how this could work, let's say that you have a toolbar that you use a lot. You have named this toolbar "sampler." You want this toolbar to be displayed when you click a button on a different toolbar. First, you need to create the new toolbar that will contain the single button that toggles the "sampler" toolbar. In this example, the new toolbar will be named "switcher."
WordBasic allows you to select button faces from a group of built-in images, and you can change them on the fly. Even though the available images are quite diverse, selecting the images you want will necessarily involve some compromises on you part. You can see the complete list of available button faces by searching for the "toolbar button images and numbers" in the Help system (use Find, not the Index). The following WordBasic macro can be assigned to a button on the "switcher" toolbar:
Sub MAIN
REM First check if the toolbar is shown or hidden
If ToolbarState("sampler") Then
REM Hide the toolbar and change the button image to "show"
ViewToolbars .Toolbar = "sampler", .Context = 0, .Hide
ChooseButtonImage .Face = 37, .Button = 1, .Context = 0, .Toolbar = "switcher"
Else
REM Show the button and change the button image to "hide"
ViewToolbars .Toolbar = "sampler", .Context = 0, .Show
ChooseButtonImage .Face = 39, .Button = 1, .Context = 0, .Toolbar = "switcher"
End If
End Sub
When you click on the button on the "switcher" toolbar, the "sampler" toolbar is either displayed or hidden, depending on the state of the toolbar when you click on the button. In addition, the image used on the "switcher" toolbar button is changed from an up arrow to a down arrow. You can use different images from the built-in library by changing the values you assign to the .Face variable.
Tip #1121 applies to Microsoft Word versions: 6 95
More Power! For some people, the prospect of creating Word macros can be scary. WordTips: The Macros can help you conquer your fears and you'll discover you're much more confident and productive as you make Word do exactly what you want. This is an invaluable source for learning macros. You are introduced to the topic in bite-sized chunks, pulled from past issues of WordTips. Learn at your own pace, exactly the way you want.