In this post, our aim is to provide you with 2 ways to show the navigation pane in one specific Word document only.
For those who use the navigation pane a lot, you must have noticed that it stays for all the documents opened in the future once it’s triggered. Thus, to close it, you would have to manually click the “Close” button. This global feature can be annoying sometime especially when we just want it open for one specific document only.
To address this issue, we need the help of Word macro.
Method 1: Macro for Documents Requiring Frequent Change of Name and Path
- Firstly, since we need to be able to run macro in a specific document, we have to alter the macro setting first. Click “File” then “Options” to open “Word Options” dialog box. Then click “Trust Center” and “Trust Center Settings” button. Next click “Macro Settings” and select “Enable all macros”. Click “OK” in both boxes.
- Now press “Alt+ F11” to open VBA editor.
- Next click “ThisDocument” under the project of this specific document.
- Click “Insert” tab and choose “Module”.
- Then double click on the module and paste the following codes on the right side space:
Sub AutoOpen() ActiveWindow.DocumentMap = True End Sub
Sub AutoClose() ActiveWindow.DocumentMap = False End Sub
- Click “Save” button.
- Now there will be a message box. Click “No”.
- In the “Save As” window, choose “Word Macro-Enabled Macro” for saving type.
- Click “Save”.
Now you will have the navigation pane open for just the specific document.
Method 2: Word Macro for Documents with Fixed Name and Path
- To start off, Open Word and press “Alt+ F11” to trigger the VBA editor.
- In the “Normal” project, click “Insert” and choose “Module”.
- Still double click on the module to open the coding area and paste the bellowing macro:
Sub AutoOpen() Dim strDocName As String Dim strDocpath As String Dim nDocName As Integer Dim nDocpath As Integer strDocName = "Sample.docx" strDocpath = "E:\Temp" ' If the two strings sort equally, Returns 0. nDocName = StrComp(ActiveDocument.Name, strDocName, vbTextCompare) nDocpath = StrComp(ActiveDocument.Path, strDocpath, vbTextCompare) If nDocName = 0 Then If nDocpath = 0 Then ActiveWindow.DocumentMap = True End If Else ActiveWindow.DocumentMap = False End If End Sub
- Next click “Save”.
Notes:
- In code line “strDocName = “Sample 2.docx””, replace the “Sample 2.docx” with your file name.
- In code line “strDocpath = “C:\Users\Public\Documents\New folder””, replace the “C:\Users\Public\Documents\New folder” with the path of the folder where the file is stored. Remember there is no “\” in the end.
Comparison of 2 Methods
Methods | Advantages | Disadvantages |
Method 1: Macro for Documents Requiring Frequent Change of Name and Path | The change of document name or path won’t affect the effect. | 1. You have to save the document as .docm type which requires a few more steps.
2. You have to alter macro settings before save the file as .docm type. 3. Sometime, the function is not very stable. |
Method 2: Word Macro for Documents with Fixed Name and Path | 1. You don’t have to save the document in another type.
2. It suits those documents with fixed name and path. |
If you want to move the document or change its name, you will have to modify the macro. |
Address Word Issues
We have encountered with Word errors more or less in our daily use. And the unexpected comes with no sign at all. For this reason, to reduce the effects of docx damage, we encourage you to hold a prominent recovering tool beforehand.
Author Introduction:
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt Excel and pdf repair software products. For more information visit www.datanumen.com
Leave a Reply