Making that many folder is insane. I am not totally following this, but....
1. if the files are in the same folder
2. and you want to select 8 of them to do your file merging
Sub YaddaMultiLine()
Dim myFiles() As String
Dim myFilesListed As String
Dim j As Long
Dim var
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.ButtonName = "OK"
.Title = "Select Parent Folder"
If .Show = 0 Then Exit Sub
If .SelectedItems.Count > 1 Then
For var = 1 To .SelectedItems.Count
ReDim Preserve myFiles(j)
myFiles(j) = .SelectedItems(var)
j = j + 1
Next
Else
myFiles(0) = .SelectedItems(1)
End If
If j <> 9 Then
MsgBox "HEY!!! You are supposed to select 8 files." & _
vbCrLf & "Macro will terminate. Try again."
Exit Sub
End If
End With
If j = 0 Then
myFilesListed = myFiles(0)
Else
For var = 0 To UBound(myFiles())
myFilesListed = myFilesListed & myFiles(var) & _
vbCrLf
Next
End If
MsgBox myFilesListed
End Sub
The code above insists on getting 8 file selected. You may not want that.
just remove it to get whatever number you want...except ONE. You cannot use
this 9as it is) to get just one file.
The point being is that you can build a list of the 8 files you want to grab,
and then process them. Like this:
Sub YaddaMultiLine()
' the other stuff to get the array of filenames
Dim r As Range
For var = 0 To Ubound(myFiles())
Set r = ActiveDocument.Range
With r
.Collapse 0
.InsertFile Filename:=myFiles(var)
End With
Next
End Sub
This process each of the arrayed filenames, and inserts it at the end of the
ActiveDocument. Do you next a page break? A Section break? Simply add one
for each iteration.
Gerry said:
How are the individual documents create and how are they named?
There is no doubt that vba can be used to combine documents, if the
individual documents that are to be combined can be identified.
I can't imagine that creating 150 separate folders to hold each set of eight
documents is the best way to go.
Thank you Graham. Sorry to be unclear.
There are 150 sets of 8 documents to join together. Each document is 1
[quoted text clipped - 68 lines]