Consulting

Results 1 to 7 of 7

Thread: How to lock Track Changes for multiple documents in one go (macro?)

  1. #1

    How to lock Track Changes for multiple documents in one go (macro?)

    Hi all,
    This is my first post here, thanks in advance for your help!
    I have 100+ Word files for which I need to lock Track Changes.
    If I need to do this for one single file, I go to Review / Track Changes / Lock Tracking / and I insert a password twice.
    But doing this for 100+ documents is quite time consuming.
    Would there be a solution to do this in one go for multiple Word files? A macro for instance?
    Many thanks!
    Claire

  2. #2
    See https://www.gmayor.com/document_batch_processes.htm

    Use the following as a user defined process

    Function LockTracking(oDoc As Document) As Boolean    On Error GoTo err_Handler
        oDoc.Protect Password:="password", _
                     NoReset:=False, _
                     Type:=wdAllowOnlyRevisions, _
                     UseIRM:=False, _
                     EnforceStyleLock:=False
        LockTracking = True
    lbl_Exit:
        Exit Function
    err_Handler:
        LockTracking = False
        Resume lbl_Exit
    End Function
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Thank you so much! I will look into this solution. I will let you know if I still have questions.
    Claire

  4. #4
    VBAX Newbie
    Joined
    Jan 2020
    Posts
    3
    Location
    Hi Graham, this works great for me with Document Batch Processes. Thank you so much! However, I'd also like to be able to reverse it using DBP. I've tried all day to figure it out, but it's beyond me. Could you provide a reversing function that will remove the protection and turn off tracking? And a side question: This would just be icing on the cake, but is it possible to have DBP run this kind of function and ask for the password when run, since in my case the passwords for locking and unlocking track changes are different from project to project?

    Thank you!
    Kerry

  5. #5
    The batch process cannot be used with documents that are protected in this way. You would need a separate process e.g.

    Sub UnLockTracking()
    
    'Graham Mayor - https://www.gmayor.com - Last updated - 15 Jan 2020
    Dim strFile As String
    Dim strPath As String
    Dim oDoc As Document
    Dim fDialog As FileDialog
    Dim strPass As String
    
        Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
        With fDialog
            .TITLE = "Select folder and click OK"
            .AllowMultiSelect = False
            .InitialView = msoFileDialogViewList
            If .Show <> -1 Then
                MsgBox "Cancelled By User", , "List Folder Contents"
                Exit Sub
            End If
            strPath = fDialog.SelectedItems.Item(1)
            Do Until Right(strPath, 1) = "\"
                strPath = strPath & "\"
            Loop
        End With
        strPass = InputBox("Enter password (case sensitive)")
    
        strFile = Dir$(strPath & "*.docx")
        While strFile <> ""
            Set oDoc = Documents.Open(strPath & strFile)
            If oDoc.ProtectionType = wdAllowOnlyRevisions Then
                oDoc.Unprotect strPass
                oDoc.Save
            End If
            oDoc.Close SaveChanges:=wdDoNotSaveChanges
            strFile = Dir$()
        Wend
    lbl_Exit:
        Set oDoc = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  6. #6
    VBAX Newbie
    Joined
    Jan 2020
    Posts
    3
    Location
    Thank you so much, Graham! I really appreciate it!

  7. #7
    VBAX Newbie
    Joined
    Jan 2020
    Posts
    3
    Location
    Please disregard.

Posting Permissions

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