Consulting

Results 1 to 8 of 8

Thread: Changing the User Name in "Track Changes" for Existing Formatting Changes

  1. #1

    Changing the User Name in "Track Changes" for Existing Formatting Changes

    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."

    formatting.jpg

    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!
    Last edited by Paul_Hossler; 01-18-2018 at 07:22 AM.

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,285
    Location
    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:

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

    Visit my website: http://gregmaxey.com

  3. #3
    Thank you! I'll give this a try.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,393
    Location
    Quote Originally Posted by devinfitzpat View Post
    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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Newbie
    Joined
    Feb 2019
    Posts
    1
    Location
    Quote Originally Posted by gmaxey View Post
    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:

    [IMG]file:///C:/Users/Maxey/AppData/Local/Temp/SNAGHTMLa188c9a.PNG[/IMG]
    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! :-)

  6. #6
    VBAX Newbie
    Joined
    Aug 2021
    Posts
    1
    Location

    Thumbs up Creative!

    Truly remakrable and creative solution!
    I made an account with vbaexpress just to appreciate this solution!

    Quote Originally Posted by gmaxey View Post
    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:

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

  7. #7
    VBAX Newbie
    Joined
    Jul 2022
    Posts
    1
    Location
    Quote Originally Posted by gmaxey View Post
    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:

    [IMG]file:///C:/Users/Maxey/AppData/Local/Temp/SNAGHTMLa188c9a.PNG[/IMG]
    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.

  8. #8
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,285
    Location
    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).
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •