' Show current output type: draft output or object output,
' and switch on request to the other output type.
'
' Switching output type:
' If there is no open draft/object output document, a new draf/object output
' document is opened; else the last draft/object document is designated as
' the active output document (to be specific: the LAST CREATED draft/object
' output WINDOW is designated as the the active output window).
'
' If you put this script under a toolbar button in the syntax window,
' you can easily switch between draft and object output without leaving the
' syntax window.
'
' This script is written with SPSS release 10.1.4
' Karel Asselberghs asselberghs@dds.nl
Sub Main
Dim objSPSSOptions As ISpssOptions
Dim objDocuments As ISpssDocuments
Dim objOutputDoc As ISpssOutputDoc
Dim objDraftDoc As ISpssDraftDoc
Dim count As Integer
Dim OutputType As Integer
Set objSPSSOptions = objSpssApp.Options
Set objDocuments = objSpssApp.Documents
OutputType = objSPSSOptions.CurrentOutputType
If OutputType = 0 Then
If MsgBox("Switch to draft output?",vbOkCancel,"Object output") <> vbOK Then
Exit All
End If
Else
If MsgBox("Switch to object output?",vbOkCancel,"Draft output") <> vbOK Then
Exit All
End If
End If
If OutputType = 0 Then ' if SPSSObjectOutput
count = objDocuments.DraftDocCount
If count = 0 Then
objSPSSOptions.CurrentOutputType = 1
Else
Set objDraftDoc = objDocuments.GetDraftDoc(count-1)
ObjDraftDoc.Designated = True
End If
Else ' if SPSSDraftOutput
count = objDocuments.OutputDocCount
If count = 0 Then
objSPSSOptions.CurrentOutputType = 0
Else
Set objOutputDoc = objDocuments.GetOutputDoc(count-1)
ObjOutputDoc.Designated = True
End If
End If
If OutputType = 1 And objSPSSOptions.CurrentOutputType = 1 Then
MsgBox "Failed to switch to Object output",,"Draft output"
ElseIf OutputType = 0 And objSPSSOptions.CurrentOutputType = 0 Then
MsgBox "Failed to switch to Draft output",,"Object output"
End If
End Sub