Expand and Collapse in Microsoft Word
Revision as of 02:31, 21 February 2017 by Kipkis (Kipkis | contribs) (importing article from wikihow)
Many web pages have "Click for More"-type buttons; when you click on the button, the page reveals more information. How can you achieve this effect in Microsoft Word documents?
Steps
- You can achieve this effect using a "macrobutton field", a bookmark, and some <acronym title="Visual Basic for Applications">VBA</acronym> code.
- First, select the part of the document you want to show when the button is clicked.
- On the Insert tab of the ribbon, click Bookmark.
- Give your bookmark a name. e.g. TextToShow
- Place the cursor where you would like your button to appear. Make sure that it is not within the bookmark area.
- Create a field by typing Ctrl-F9. You should see curly brackets {} with the cursor blinking inside
- Type: MACROBUTTON MYMACRO Show
- Type Alt-F9 to hide the field codes. Now you should just see the word Show
- Open the Visual Basic editor by typing Alt-F11
- Double-click on This Document under YourDocumentName > Microsoft Word Objects in the Project pane.
- Create the macro. In the code window, place the following code:
Sub MYMACRO()
ActiveDocument.Bookmarks("TextToShow").Range.Font.Hidden = Not ActiveDocument.Bookmarks("TextToShow").Range.Font.Hidden
End Sub - Now try clicking on the word (button) Show. Each click should hide or show the text.
Tips
- Alternatively you can use the 3rd-party Word add-in More Addin with which you can add collapse/expand segments to your document with one click.
Related Articles
- Indent the First Line of Every Paragraph in Microsoft Word
- Recover Word Documents
- Create a Drop Cap in a Word Document
- Choose the Most Appropriate Font Colour in Microsoft Word