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...
Step-by-Step Guide
-
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. -
Step 2: a bookmark
-
Step 3: and some <acronym title="Visual Basic for Applications">VBA</acronym> code.
-
Step 4: select the part of the document you want to show when the button is clicked.
-
Step 5: On the Insert tab of the ribbon
-
Step 6: click Bookmark.
-
Step 7: Give your bookmark a name.
-
Step 8: Place the cursor where you would like your button to appear.
-
Step 9: Create a field by typing Ctrl-F9.
-
Step 10: Type: MACROBUTTON MYMACRO Show
-
Step 11: Type Alt-F9 to hide the field codes.
-
Step 12: Open the Visual Basic editor by typing Alt-F11
-
Step 13: Double-click on This Document under YourDocumentName > Microsoft Word Objects in the Project pane.
-
Step 14: Create the macro.
-
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
Joan Bishop
Committed to making lifestyle accessible and understandable for everyone.
Rate This Guide
How helpful was this guide? Click to rate: