Skip to content

Instantly share code, notes, and snippets.

@phongphuhanam
Created February 13, 2023 01:32
Show Gist options
  • Select an option

  • Save phongphuhanam/40be3de978cbd278d17f19590a7fd962 to your computer and use it in GitHub Desktop.

Select an option

Save phongphuhanam/40be3de978cbd278d17f19590a7fd962 to your computer and use it in GitHub Desktop.
Useful VBA scripts for Word

Usefull VBA scripts for Word

VBA

  • Apply style to all table
Sub AutoTableFormat()

    Dim tbl As Table
    For Each tbl In ActiveDocument.Tables
        tbl.Range.Style = ActiveDocument.Styles("Table Text")
    Next

End Sub
  • Change tracked content to different color
Sub tracked_to_highlighted()           
    tempState = ActiveDocument.TrackRevisions
    ActiveDocument.TrackRevisions = False    
    For Each Change In ActiveDocument.Revisions        
        Set myRange = Change.Range
        myRange.Revisions.AcceptAll
        myRange.HighlightColorIndex = wdGreen            
    Next    
    ActiveDocument.TrackRevisions = tempState
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment