How to Expand and Collapse in Microsoft Word

You can achieve this effect using a "macrobutton field", a bookmark, and some VBA 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...

15 Steps 1 min read Advanced

Step-by-Step Guide

  1. Step 1: You can achieve this effect using a "macrobutton field"

    e.g.

    TextToShow , Make sure that it is not within the bookmark area. , You should see curly brackets {} with the cursor blinking inside ,, Now you should just see the word Show ,,, 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 , Each click should hide or show the text.
  2. Step 2: a bookmark

  3. Step 3: and some <acronym title="Visual Basic for Applications">VBA</acronym> code.

  4. Step 4: select the part of the document you want to show when the button is clicked.

  5. Step 5: On the Insert tab of the ribbon

  6. Step 6: click Bookmark.

  7. Step 7: Give your bookmark a name.

  8. Step 8: Place the cursor where you would like your button to appear.

  9. Step 9: Create a field by typing Ctrl-F9.

  10. Step 10: Type: MACROBUTTON MYMACRO Show

  11. Step 11: Type Alt-F9 to hide the field codes.

  12. Step 12: Open the Visual Basic editor by typing Alt-F11

  13. Step 13: Double-click on This Document under YourDocumentName > Microsoft Word Objects in the Project pane.

  14. Step 14: Create the macro.

  15. Step 15: Now try clicking on the word (button) Show.

Detailed Guide

e.g.

TextToShow , Make sure that it is not within the bookmark area. , You should see curly brackets {} with the cursor blinking inside ,, Now you should just see the word Show ,,, 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 , Each click should hide or show the text.

About the Author

J

Joan Bishop

Committed to making lifestyle accessible and understandable for everyone.

77 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: