Show or not show bookmark indicators in Word documents from Word, Access, or another VBA application.
Download zipped BAS file with module that you can import into Word and/or any VBA application mod_aWord_BookmarksShowNotshow_s4p__BAS.zip
If you have trouble with the downloaded file, remember to unblock the original ZIP file, (aka remove Mark of the Web), BEFORE extracting file(s). Here are steps to do that: https://msaccessgurus.com/MOTW_Unblock.htm
'*************** Code Start ***************************************************** ' module name: mod_aWord_BookmarksShowNotshow_s4p '------------------------------------------------------------------------------- ' Purpose : VBA to show or hide bookmarks in the Word document ' run from Word or use automation ' Author : crystal (strive4peace) ' This code: https://msaccessgurus.com/VBA/aWord_BookmarksShowNotshow.htm ' LICENSE : ' You may freely use and share this code, but not sell it. ' Keep attribution. Use at your own risk. '------------------------------------------------------------------------------- Sub aWord_BookmarksShowNotshow_s4p() '240821 strive4peace ' toggle bookmark display in Word document ' run from Word or use automation from Access, Excel, or another VBA application 'CLICK HERE 'Press F5 to run Dim oWord As Object 'Word.Application 'Initialize Word On Error Resume Next Set oWord = GetObject(, "Word.Application") On Error GoTo Proc_Err If oWord Is Nothing Then 'do nothing MsgBox "Word isn't open",, "Can't get Word Object" Exit Sub End If With oWord.ActiveWindow.View .ShowBookmarks = Not .ShowBookmarks End With Proc_Exit: On Error Resume Next Set oWord = Nothing On Error GoTo 0 Exit Sub Proc_Err: MsgBox Err.Description _ ,, "ERROR " & Err.Number _ & " aWord_BookmarksShowNotshow_s4p" Resume Proc_Exit Resume End Sub '*************** Code End ******************************************************' Code was generated with colors using the free Color Code add-in for Access
Help: View object (Word)
To show or hide bookmark indicators from Word Options: Advanced, Show document content, check or uncheck 'Show bookmarks'
To insert a Bookmark, from the ribbon:
Bookmark names in Word:
When you have bookmarks in a Word document, it's nice to quickly show or hide the indicators (Word calls them annotations).
In Word, you can add this code to your Normal template so you can run it anytime you're in Word. It also works from another application such as Access or Excel. Late binding is used so no need to reference the Microsoft Word #.# Object Library