stecstec
11-25-2005, 02:50 AM
I've got a master document where I need to open the subdocuments and print them in the order they appear in the master. So far, I've managed to code this (see below) but they print in reverse order they appear in the master document.
Would there be any way of reversing the order of the array for the subdocuments using the "For..Each" routine?
cheers, steve.
Sub PrintAll()
Dim objDoc As Document
Dim sDocName As String
sDocName = ActiveDocument.Name
On Error Resume Next
For Each objDoc In Application.Documents
If InStr(objDoc, sDocName) = 0 Then
objDoc.PrintOut
End If
Next objDoc
For Each objDoc In Application.Documents
If InStr(objDoc, sDocName) = 0 Then
objDoc.Close
End If
Next objDoc
Set objDoc = Nothing
End Sub
Sub OpenSubDocs()
Dim SubDoc As Subdocument
For Each SubDoc In Selection.Range.Subdocuments
SubDoc.Open
Next SubDoc
Call PrintAll
End Sub
Would there be any way of reversing the order of the array for the subdocuments using the "For..Each" routine?
cheers, steve.
Sub PrintAll()
Dim objDoc As Document
Dim sDocName As String
sDocName = ActiveDocument.Name
On Error Resume Next
For Each objDoc In Application.Documents
If InStr(objDoc, sDocName) = 0 Then
objDoc.PrintOut
End If
Next objDoc
For Each objDoc In Application.Documents
If InStr(objDoc, sDocName) = 0 Then
objDoc.Close
End If
Next objDoc
Set objDoc = Nothing
End Sub
Sub OpenSubDocs()
Dim SubDoc As Subdocument
For Each SubDoc In Selection.Range.Subdocuments
SubDoc.Open
Next SubDoc
Call PrintAll
End Sub