Revision Author Word Add-in (Visual Basic for Applications) example

Revision Author Word Add-in (Visual Basic for Applications) example

Revision

Represents revision author (the owner who made changes) in a document where changes have been tracked (for more info track revision changes please refer my previous article Track changes in multiple documents). The Author is the property of Revision object in Word Object. This is very useful when you want to track who all made the changes in your document.

To enable track changes in a document follow the steps:

  1. Navigate Review ribbon tab
  2. Click on Track Changes button and select Track Changes from the dropdown under Tracking group as shown below

Once you enable the track changes in a document, the document is ready to track the changes. You can share the document with other users and changes made by other users would be tracked as shown below:

Author

Public Sub GetRevisionAuthor()
    'Declare document object
    Dim oDocument As Document
    'Set active document reference
    Set oDocument = ActiveDocument
    
    Dim oRevision As Revision
    'Iterate each revision
    For Each oRevision In oDocument.Revisions
        Debug.Print oRevision.Author
    Next oRevision
End Sub

Date

Public Sub GetRevisionDate()
    'Declare document object
    Dim oDocument As Document
    'Set active document reference
    Set oDocument = ActiveDocument
    
    Dim oRevision As Revision
    'Iterate each revision
    For Each oRevision In oDocument.Revisions
        Debug.Print oRevision.Author
        Debug.Print oRevision.Date
    Next oRevision
End Sub

Accept

Public Sub AcceptRevision()
    'Declare document object
    Dim oDocument As Document
    'Set active document reference
    Set oDocument = ActiveDocument
    
    Dim oRevision As Revision
    'Iterate each revision
    For Each oRevision In oDocument.Revisions
        'Accept revision
        oRevision.Accept
    Next oRevision
End Sub

Reject

Public Sub RejectRevisionChanges()
    'Declare document object
    Dim oDocument As Document
    'Set active document reference
    Set oDocument = ActiveDocument
    
    Dim oRevision As Revision
    'Iterate each revision
    For Each oRevision In oDocument.Revisions
        'Reject revision
        oRevision.Reject
    Next oRevision
End Sub

Leave a Reply

Your email address will not be published.