Word VBA - extract Revision Author information
If you want to know the details of track revisions, for example, Author name etc the following code will help you:
Sub Get_TrackRevision_Author() Dim oRev As Revision Dim oRange As Range ' ----------------------------------------------------------- ' Change the line below to suit your needs ' ----------------------------------------------------------- Set oRange = Selection.Range ' ----------------------------------------------------------- ' Coded by Shasur for http://vbadud.blogspot.com ' ----------------------------------------------------------- For Each oRev In oRange.Revisions MsgBox oRev.Range.Text & " " & oRev.Author Next oRev End Sub
The following code provides you more information (like if the comment is inserted / deleted)
If oRev.Type = wdRevisionDelete Then MsgBox oRev.Range.Text & " deleted by " & oRev.Author ElseIf oRev.Type = wdRevisionInsert Then MsgBox oRev.Range.Text & " added by " & oRev.Author Else MsgBox oRev.Range.Text & " " & oRev.Author End If
If you want to know Date of Revision using VBA then the following can be added
MsgBox oRev.Range.Text & " " & oRev.Author & " " & oRev.Date
When i run the above code in a word file it gets error while there is track changes in table, how to avoid this error. Error is 'Method 'author' in object 'Revision' failed.
ReplyDeleteHi Iniyal
ReplyDeleteCan you try by making a revision (either by inserting/ deletion) the comment.
Just want to know if there is a problem with that particular table / revision
Please also mention the versin of Word you are using