terrif
09-17-2015, 04:38 AM
Can anyone tell me how I can write the VBA code to create a new document and merge comments from multiple documents in one directory. I have the blow code, but it also includes the main document comments, but that is not needed. Also is there any way to add in the document name as well associated to the comments. So you would have the document name and then all the comments from that document. This would loop until it gets through the entire directory.
I am not VBA expert at all so any assistance on this would be much appreciated.
Sub MergeDocs()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Dim i As Long
Const strFolder = "C:\Users\tefe\Desktop\Merge\"
Set MainDoc = Documents.Add
strFile = Dir$(strFolder & "*.docx")
Do Until strFile = “”
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
Selection.InsertBreak Type:=wdPageBreak
rng.InsertFile strFolder & strFile
strFile = Dir$()
Loop
'
'
'End Sub
Thanks,
TF
I am not VBA expert at all so any assistance on this would be much appreciated.
Sub MergeDocs()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Dim i As Long
Const strFolder = "C:\Users\tefe\Desktop\Merge\"
Set MainDoc = Documents.Add
strFile = Dir$(strFolder & "*.docx")
Do Until strFile = “”
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
Selection.InsertBreak Type:=wdPageBreak
rng.InsertFile strFolder & strFile
strFile = Dir$()
Loop
'
'
'End Sub
Thanks,
TF