PDA

View Full Version : Navigation Pane VBA Document_Close()



jnorden
01-30-2015, 02:31 PM
A co-worker had asked if there was a way to automatically open the navigation pane within a specific Word document when opened. I suggested using VBA to program events to show the navigation pane when that file is opened. While I was able to succesfully create this Open event, the Close event does not work the way I would like.

Once the user closes the document and opens a new unrelated document, the navigation pane is still visible in the new document since it was still visible when Word closed the last time.

It is wierd because I have set a Document_Close event to close the navigation pane when the document is closed. It does not work as written below, but I did find it does work the way I intend if I include a message box at the end of the Close event. I do not know why this makes it work.

I do not want a message box to appear when closed, so this is an unacceptable workaround. I do not see why I can't get this to work. Is there a workaround? What am I missing? I have spent 4 hours trying to solve this and haven't found a solution via google search. I appreciate any information or help. Thanks in advance!

Private Sub Document_Open()
ActiveWindow.DocumentMap = True
End Sub

Private Sub Document_Close()
ActiveWindow.DocumentMap = False
End Sub