Access

Alternar visualización de marcadores en documentos de Word usando VBA

Vba

Módulo estándar

'*************** 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: 
' 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 ******************************************************

‘ El código se generó con colores usando el complemento gratuito Color Code para Access

Publicaciones relacionadas

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Botón volver arriba