PDA

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



Claire C
08-27-2019, 02:56 AM
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

gmayor
08-27-2019, 08:36 PM
See https://www.gmayor.com/document_batch_processes.htm (http://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

Claire C
08-27-2019, 11:53 PM
Thank you so much! I will look into this solution. I will let you know if I still have questions.
Claire

kerjsmit
01-14-2020, 03:06 PM
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

gmayor
01-14-2020, 09:45 PM
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

kerjsmit
01-16-2020, 02:10 PM
Thank you so much, Graham! I really appreciate it!

kerjsmit
01-16-2020, 02:37 PM
Please disregard.