I would like to know if there is a way to change the author of revisions in a document, I've found the way to change the author of comments but no for the revisions part. I've tried to find a property/method in the Revisions.object documentation to change that but I find nothing.
As I said I've already tried to do this:
Sub ChangeCommentCreator()
Dim I As Long
Dim Novo As String
Dim Corto As String
If Selection.Comments.Count = 0 Then
MsgBox "No comments in your selection!", vbInformation, "Alerta"
Exit Sub
End If
Novo = InputBox("New author name?", "Alerta")
Corto = InputBox("New author initials?", "Alerta")
If Novo = "" Or Corto = "" Then
MsgBox "The author name/initials can’t be empty.", vbInformation, "Alerta"
Exit Sub
End If
With Selection
For I = 1 To .Comments.Count
.Comments(I).Author = Novo
.Comments(I).Initial = Corto
Next I
End With
End Sub
I'm going in the right way or there is just no way to change this?
Revisions automatically use the selected User Name in the UI. The language reference for the Revisions
's Author
property states:
Returns the name of the user who made the specified tracked change. Read-only String.
So there's no direct way using VBA and the object model to change that.
It is possible to change it by editing the underlying Word Open XML, as illustrated in the code that follows. I notice, however, that this appears to confuse Word - after running the macro no revisions are recognized in the document. Only after saving, closing and re-opening does Word "see" the revisions, again.
Sub ChangeAuthorName()
Dim sWOOXML As String
Dim findAuthor As String
Dim replaceAuthor As String
findAuthor = "w:author=" & Chr(34) & "Cindy Meister" & Chr(34)
replaceAuthor = "w:author=" & Chr(34) & "unknown" & Chr(34)
sWOOXML = ActiveDocument.content.WordOpenXML
sWOOXML = Replace(sWOOXML, findAuthor, replaceAuthor)
ActiveDocument.content.InsertXML sWOOXML
End Sub
Note that this will likely also change the author's name for comments. The more "elegant" way to do this would be to leverage an XML parser (such as MSXML) and work with the specific nodes. Or even use a package that works on the closed document and edits the Word Open XML. But this is the simplest way using straight Word VBA.