PDA

View Full Version : [SOLVED:] Changing the User Name in "Track Changes" for Existing Formatting Changes



devinfitzpat
01-07-2018, 05:24 PM
Hello all, I'm new to VBA and inexperienced with code in general, and I was hoping someone could help me with a question. I'm collaborating on editing a document with multiple users, all of whom are making comments and formatting changes, and we want to present our edits to the author under a single name. I recently used code I found online (by Allen Wyatt, which I would link to if I were not newly registered here) to run a macro that efficiently replaced all of the user names for comments with a single name, which was incredibly helpful.

However, it didn't replace the user name of those who had made formatting changes, as can be seen in this screenshot, where I ran the code to replace the user name of those writing comments with "Test Author."

21316

Does anyone know how I might modify the code in order to replace the user name of those making formatting changes as well? Here is the code:


Sub ChangeCommentAuthor()
Dim J As Integer
Dim sAuthorname As String
Dim sInitial As String

If Selection.Comments.Count = 0 Then
MsgBox "No comments in your selection!", _
vbCritical + vbOKOnly, "Cannot perform action"
Exit Sub
End If

sAuthorname = InputBox("New author name?", _
"Comments Author Name")
If sAuthorname = "" Then End

sInitial = InputBox("New author initials?", _
"Comments Initials")
If sInitial = "" Then End

With Selection
For J = 1 To .Comments.Count
.Comments(J).Author = sAuthorname
.Comments(J).Initial = sInitial
Next J
End With
End Sub

Thank you very much in advance for any assistance!

gmaxey
01-08-2018, 07:09 AM
Unfortunately unlike the comments author property, the revision author property is read only and cannot be changed with VBA. What you can do is 1. SAVE a copy of the document. 2. Change the document extension from .docx to .zip. Then use a compression utility e.g., WinZip to unzip the file. 3. Open the word folder 4. Open the document.xml file then find and replace the revision editors. A revision editor will look something like this:

file:///C:/Users/Maxey/AppData/Local/Temp/SNAGHTMLa188c9a.PNG
5. Save the document.xml file then copy the word folder back to the zip file. 6. Change the .zip extension back to .docx.

devinfitzpat
01-08-2018, 12:20 PM
Thank you! I'll give this a try.

Paul_Hossler
01-18-2018, 07:24 AM
Thank you! I'll give this a try.

Also, I added CODE tags around your macro. You can use the [#] icon to insert opening and closing CODE tags next time to paste your macro code between them to format

Krupier2
02-23-2019, 08:57 AM
Unfortunately unlike the comments author property, the revision author property is read only and cannot be changed with VBA. What you can do is 1. SAVE a copy of the document. 2. Change the document extension from .docx to .zip. Then use a compression utility e.g., WinZip to unzip the file. 3. Open the word folder 4. Open the document.xml file then find and replace the revision editors. A revision editor will look something like this:

file:///C:/Users/Maxey/AppData/Local/Temp/SNAGHTMLa188c9a.PNG
5. Save the document.xml file then copy the word folder back to the zip file. 6. Change the .zip extension back to .docx.

What an elegant solution! Saved my behind, thanks ever so much! :-)

jvpjacob
08-16-2021, 11:46 PM
Truly remakrable and creative solution!
I made an account with vbaexpress just to appreciate this solution!


Unfortunately unlike the comments author property, the revision author property is read only and cannot be changed with VBA. What you can do is 1. SAVE a copy of the document. 2. Change the document extension from .docx to .zip. Then use a compression utility e.g., WinZip to unzip the file. 3. Open the word folder 4. Open the document.xml file then find and replace the revision editors. A revision editor will look something like this:

file:///C:/Users/Maxey/AppData/Local/Temp/SNAGHTMLa188c9a.PNG
5. Save the document.xml file then copy the word folder back to the zip file. 6. Change the .zip extension back to .docx.

Trung Vu
07-15-2022, 01:27 AM
Unfortunately unlike the comments author property, the revision author property is read only and cannot be changed with VBA. What you can do is 1. SAVE a copy of the document. 2. Change the document extension from .docx to .zip. Then use a compression utility e.g., WinZip to unzip the file. 3. Open the word folder 4. Open the document.xml file then find and replace the revision editors. A revision editor will look something like this:

file:///C:/Users/Maxey/AppData/Local/Temp/SNAGHTMLa188c9a.PNG
5. Save the document.xml file then copy the word folder back to the zip file. 6. Change the .zip extension back to .docx.

That's amazing. Same to another guy above, I created this account just to thank you, gmaxey, for your solution and sharing. You saved me hours of work and from failing my client's deadline.

gmaxey
07-15-2022, 06:13 AM
Thanks for your feedback. This is something I love about these forums. A little help can spread and go a long way (Oregon, Czech Republic, Bahrain, Vietnam).