In this article, we are going to offer you 2 smart ways to collapse or expand parts of your Word document.
Every now and then, have you wonder how wonderful it would be if you can collapse a certain range of document to view two nonconsecutive parts? The good news is there is this built-in feature in Word 2013 and versions later.
If you have Word 2013 or version later, you may refer to this link to know more about the function: https://support.microsoft.com/en-us/office/collapse-or-expand-parts-of-a-document-701786e0-95e2-40bf-bfe5-f0233cd3520c
However, if you are using Word 2010 or versions earlier, there is no such luck. For this reason, we found 2 solutions you can adopt in versions prior to Word 2013.
Method 1: Collapse or Expand a Single Part of a Document
- First off, select the text you want to collapse.
- Next click “Insert” tab.
- Then click “Bookmark” in “Links” group to open the “Bookmark” dialog box.
- Enter a bookmark name in the text box and click “Add” to create a bookmark for the selected content.
- Now press “Alt+ F11” to open the VBA editor.
- Next click “Normal” and then the “Insert” tab.
- Choose “Module”.
- Double click on module to open the coding area on the right side and paste the following codes:
Sub CollapseOrExpandTheSelectedText1() ActiveDocument.Bookmarks("Introduction").Range.Font.Hidden = _ Not ActiveDocument.Bookmarks("Introduction").Range.Font.Hidden End Sub
- You can change the macro name to whatever you want to call it.
- The “Introduction” refers to the bookmark name. Make sure it is as same as the name you entered in step 4.
- Click “Save” to save the macro.
- Next put insertion pointer near the bookmark but never inside it. For instance, we place it at the line above the selected text.
- Then press “Ctrl+ F9” to insert a field.
- Inside the field, enter the bellowing codes:
MACROBUTTON CollapseOrExpandTheSelectedText1 Introduction
- The “CollapseOrExpandTheSelectedText1” is the macro name in step 8.
- The “Introduction” is the label you want to show on the button.
- Now press “Alt+ F9” and you shall see the button.
- Double click on the button to either expand or collapse the text.
Method 2: Collapse or Expand Multi-part of a Document
If you apply method 1 to create several buttons to collapse or expand contents, you can use the following method to show or hide the texts in batches.
- Repeat from step 5 to 8 in method 1.
- Then to collapse all texts, paste this macro there:
Sub CollapseAllSelectedTexts() Dim objBookmark As Bookmark For Each objBookmark In ActiveDocument.Bookmarks objBookmark.Range.Font.Hidden = True Next End Sub
To expand all texts, you will need this one:
Sub ExpandAllSelectedTexts() Dim objBookmark As Bookmark For Each objBookmark In ActiveDocument.Bookmarks objBookmark.Range.Font.Hidden = False Next End Sub
- Next click “Run” or hit “F5”.
Besides, you can take step 10 to 14 in method 1 to create buttons in the document to expand or collapse all texts at once.
Cope with the Consequences of Word Failure
Word fails from time to time. And there are consequences. Some of them are fine while others can get you busy in recovering the data back. If the latter is your case, you’d better choose a doc recovery tool to help you with the business.
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xlsx damage and pdf repair software products. For more information visit www.datanumen.com