My Assistant
![]() ![]() |
|
|
Dec 28 2011, 08:44 PM
Post
#1
|
|
|
New Member Posts: 18 |
Hello,
I have a directory which has several copies of the same word document. A different person has added comments in each copy and how to use a macro to combine these comments into one file. Essentially, repeat the command 'Compare and merge documents' legal blackline a number of times.. Could anyone help please? thanks in advance. |
|
|
|
Jan 3 2012, 09:54 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 9,266 From: Wisconsin |
bwitheht,
Here's a fairly simple macro that should get you well on your way: CODE Sub CombineFolderOfFiles() ' ' CombineFolderOfFiles Macro ' Close all open documents before beginning Documents.Close SaveChanges:=wdPromptToSaveChanges strFolder = "H:\Data Files\" ' Create a new, blank file to copy all of the contents into Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0 ' Add a short header describing which folder the file summary is for Selection.Text = "Combination of files from folder: " & strFolder & vbCrLf Selection.EndKey Unit:=wdStory ' Get the first filename myFile = Dir(strFolder & "*.doc*") While myFile <> "" ' Open document Set myDoc = Documents.Open(strFolder & myFile) ' Selection.HomeKey Unit:=wdStory ' Copy the entire file's contents... Selection.WholeStory Selection.Copy ' Close the file myDoc.Close SaveChanges:=wdSaveChanges ' Paste the file contents into the new file Selection.Paste ' Get the next filename myFile = Dir() Wend End Sub Remember to change the strFolder = "H:\Data Files\" bit to the appropriate folder name. Hope this helps, Dennis |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 10:29 PM |