The relevant part of the add-in is as follows. I suspect that the document
may be being closed before it has finished spooling. If you disable the
lines
oPrDoc.PrintOut
and
oPrDoc.Close wdDoNotSaveChanges
by adding an apostrophe to the start of each line and run the macro, you
should end up with a document (oDoc) that contains the list of documents in
the order they are to be printed.
If that is OK then try introducing a delay eg
For i = 1 To 500000000
Next i
between
oPrDoc.PrintOut
oPrDoc.Close wdDoNotSaveChanges
thus
oPrDoc.PrintOut
For i = 1 To 500000000
Next i
oPrDoc.Close wdDoNotSaveChanges
Which will add a delay of around 10 seconds (depending on the speed of your
PC) - much shorter than the print cycle, but may give sufficient delay to
ensure that the document is spooled correctly.
Private Sub CommandButton1_click()
Unload Me
For i = 0 To ListBox2.ListCount - 1
strPath = sBatchFolder & ListBox2.List(i)
oDoc.Range.InsertAfter strPath
If i < ListBox2.ListCount - 1 Then
oDoc.Range.InsertAfter vbCr
End If
Next i
Application.ScreenUpdating = False
For i = 1 To oDoc.Paragraphs.Count
Set oRng = oDoc.Paragraphs(i).Range
oRng.End = oRng.End - 1
WordBasic.DisableAutoMacros 1
'************************************
Set oPrDoc = Documents.Open(oRng.Text)
oPrDoc.PrintOut
oPrDoc.Close wdDoNotSaveChanges
'************************************
WordBasic.DisableAutoMacros 0
Next i
oDoc.Close wdDoNotSaveChanges
Application.ScreenUpdating = True
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>