'Begin Description
' Print all spo files meeting a "path\filemask"
' This script processes all files meeting a given mask, eg "*.spo", "out*.spo"
' and located in a given folder
' Say first 2 files are named output1.spo and myoutput.spo
' then output1.spo is opened and printed
' then myoutput.spo opened and printed.
'End Description
' Code by rlevesque@videotron.ca 2002/08/01
' http://pages.infinit.net/rlevesqu/index.htm
Option Explicit
Sub Main
Dim objDocuments As ISpssDocuments
Dim objOutputDoc As ISpssOutputDoc
Dim strPath As String
Dim strFileMask As String
Dim strFname As String
Dim intCount As Integer
Dim I As Integer
'define file path and mask
strPath ="c:\temp\"
strFileMask ="*.spo"
'Get the first output file name
strFname = Dir$(strPath & strFileMask)
Set objDocuments = objSpssApp.Documents
While strFname <> ""
Debug.Print strFname
' Open the Output, make it visible, select all Pivot Tables:
Set objOutputDoc = objSpssApp.OpenOutputDoc(strPath & strFname)
objOutputDoc.Visible = True
' objOutputDoc.PrintDoc
' To conserve memory, close all but the designated output document
'(using a simple "objOutputDoc.Close" crashes spsswin.exe!)
intCount = objDocuments.OutputDocCount
If intCount > 1 Then
For I = intCount - 1 To 0 Step -1
Set objOutputDoc = objDocuments.GetOutputDoc(I)
If Not objOutputDoc.Designated Then
objOutputDoc.Close
End If
Next
End If
'Get next output file name
strFname = Dir$()
Wend
Set objOutputDoc = Nothing
End Sub