If you have the filenames complete with their filepaths in column A of an Excel worksheet (with a header row), listed in the order they are to be printed, and with the number of copies for each row to be printed in Column B , without gaps, (see attached example), then the following macro should print them in the order and with the quantities indicated:
Option Explicit
Const strWorkbook As String = "C:\Path\Forum\PrintList.xlsx" 'The workbook with the list
Const strSheet = "Sheet1" 'The worksheet with the list
Sub PrintBatch()
Dim oDoc As Document
Dim arr() As Variant
Dim iRows As Long
Dim bBackground As Boolean
bBackground = Options.PrintBackground
Options.PrintBackground = False
arr = xlFillArray(strWorkbook, strSheet)
For iRows = 0 To UBound(arr, 2)
MsgBox arr(0, iRows) & vbCr & arr(1, iRows)
Set oDoc = Documents.Open(arr(0, iRows))
PrintDoc oDoc, Val(arr(1, iRows))
oDoc.Close SaveChanges:=wdDoNotSaveChanges
Next iRows
Options.PrintBackground = bBackground
lbl_Exit:
Set oDoc = Nothing
Exit Sub
End Sub
Sub PrintDoc(oDoc As Document, iCopies As Integer)
oDoc.PrintOut Range:=wdPrintAllDocument, _
Item:=wdPrintDocumentWithMarkup, _
Copies:=iCopies, _
Pages:="", _
PageType:=wdPrintAllPages, _
Collate:=True, _
Background:=False, _
PrintToFile:=False, _
PrintZoomColumn:=0, _
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
lbl_Exit:
Exit Sub
End Sub
Private Function xlFillArray(strWorkbook As String, _
strWorksheetName As String) As Variant
Dim RS As Object
Dim CN As Object
Dim iRows As Long
strWorksheetName = strWorksheetName & "$]"
Set CN = CreateObject("ADODB.Connection")
CN.Open ConnectionString:="Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & strWorkbook & ";" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
Set RS = CreateObject("ADODB.Recordset")
RS.Open "SELECT * FROM [" & strWorksheetName, CN, 2, 1
With RS
.MoveLast
iRows = .RecordCount
.MoveFirst
End With
xlFillArray = RS.GetRows(iRows)
If RS.State = 1 Then RS.Close
Set RS = Nothing
If CN.State = 1 Then CN.Close
Set CN = Nothing
lbl_Exit:
Exit Function
End Function