PDA

View Full Version : Automated Revision Merge



SpencerPrime
02-21-2016, 04:32 PM
Hi all. I'm a VBA newbie but have experience scripting in other contexts. I've recently started working for a publication, and I was a little shocked to find that they were manually combining tracked edits from nearly a hundred editors using cut and paste. I fully intend to at least get them using Word's built in merge feature, but I thought it'd be even nicer to automate the entire process. Pulling from various sources I've found online, I wrote the following macro.


Sub MergeCCs()
Dim sMyDir As String
Dim sDocName As String
' The path to obtain the files.
sMyDir = "C:\my\source\directory\"
sDocName = Dir(sMyDir & "*.DOCX")
While sDocName <> ""
' Merge the file
ActiveDocument.Merge "C:\my\source\directory" + sDocName, wdMergeTargetCurrent, True, wdFormattingFromCurrent
' Get next file name.
sDocName = Dir()
Wend
End Sub


Ideally, it would be run on a clean version of the document and merge in all of the tracked changes and comments contained in the files within an input folder. It seems to be pulling this off perfectly, with one exception: After running the macro, there are tracked changes In seemingly random places that are attributed to me or the author of the clean document (neither of which were among the merged editors).

Can anyone explain what is going on here exactly? I am using Word 2016.

Additionally, when performing a merge manually, there is an option to apply changes at the character level rather than the word level. Is there a way to toggle this using .merge? There does not appear to be an argument for it in the documentation that I found.

And, of course, my apologies if any of this has been asked before or if I'm at all non-compliant with forum standards. I performed a search and read through the stickied threads without seeing anything too relevant.