Expand and Collapse in Microsoft Word

Revision as of 02:31, 21 February 2017 by Kipkis (Kipkis | contribs) (importing article from wikihow)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

  1. You can achieve this effect using a "macrobutton field", a bookmark, and some <acronym title="Visual Basic for Applications">VBA</acronym> code.
  2. First, select the part of the document you want to show when the button is clicked.
  3. On the Insert tab of the ribbon, click Bookmark.
  4. Give your bookmark a name. e.g. TextToShow
  5. Place the cursor where you would like your button to appear. Make sure that it is not within the bookmark area.
  6. Create a field by typing Ctrl-F9. You should see curly brackets {} with the cursor blinking inside
  7. Type: MACROBUTTON MYMACRO Show
  8. Type Alt-F9 to hide the field codes. Now you should just see the word Show
  9. Open the Visual Basic editor by typing Alt-F11
  10. Double-click on This Document under YourDocumentName > Microsoft Word Objects in the Project pane.
  11. 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
  12. 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