1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
'SPSS AnswerNet: Result
'Solution ID: 100006377

'Title:
'Removing "Statistics", "Case Processing Summary", Or Notes tables from Output

'Description:
'Q.
'I would Like To remove All "Statistics" And "Case Processing Summary"
'tables from my Output. I don't want them hidden, I want to remove them
'along With the "Notes" tables. Is there a way I can Do this With a
'Script?

'A.
'The "Clean Navigator.sbs" script (In the SPSS\\Scripts directory) Is
'intended To make it easy To delete items, either by Type Or label.
'Here's how you might edit the script to remove all three types of
'tables from your Output. Just use Utilities->Run Script To start the
'script, Or add a menu item Or toolbar button For it.

'The only change made Is In Sub Main, To which two lines have been
'added immediately after the existing

'Call SelectAndRemoveOutputItem(intType, strLabel) 'Call procedure below

'With specified parameters but before End Sub. The two lines are:

'Call SelectAndRemoveOutputItem(SPSSPivot, "Case Processing Summary")
'Call SelectAndRemoveOutputItem(SPSSPivot, "Statistics")

'The first of the three Calls could be omitted To retain Notes tables.
'Additional labels Or other types of items may also be specified.

'The edited Sub Main Is reproduced below For convenience.

Sub Main()
'The main procedure sets parameters to determine what
'output items get deleted, and then calls the
'SelectAndRemoveOutputItem procedure to do the real work.

'Declare variables for parameters

Dim intType As Integer 'Type of output item to delete, expressed as an integer
Dim strLabel As String 'Item label displayed in left pane of Output Navigator

intType = SPSSNote 'Type to delete. See help on "SpssType property" for valid types
'strLabel = "Notes" 'Label to delete

'********************************************************************
'You can edit the above lines to delete items of a different type.
'See help on the SpssType property for the complete list of types.
'Labels are case-sensitive (meaning that "Case Processing Summary"
'is not the same as "case processing summary")

'For example, to delete all Case Processing Summaries, specify:
'intType = SpssPivot
'strLabel = "Case Processing Summary"
'*********************************************************************

'Call SelectAndRemoveOutputItem(intType, strLabel) 'Call procedure below with specified parameters
Call SelectAndRemoveOutputItem(SPSSPivot, "Case Processing Summary")
Call SelectAndRemoveOutputItem(SPSSPivot, "Observation Calculer Rйcapituler")
Call SelectAndRemoveOutputItem(SPSSPivot, "Statistics")
Call SelectAndRemoveOutputItem(SPSSPivot, "Statistiques")

End Sub

Sub SelectAndRemoveOutputItem(intType As Integer, Optional strLabel As Variant)
 'This procedure iterates through output items and deletes all output
 'items that match the specified search type and label.

    'Variable declarations

	Dim objOutputDoc As ISpssOutputDoc
	Dim objItems As ISpssItems
	Dim objItem As ISpssItem
	 'By convention, object variable names begin With "obj".
	 'OutputDoc, ISpssItems, And ISpssItem are the names of SPSS object classes.
	 'For example, the first declaration above declares an object variable named
	 '"objOutputDoc" and assigns it to the OutputDoc Object
	 'class. Below, that variable is set to the designated output document
	 'in order to access the items in that output document.

	Dim intCount As Integer				'total number of output items
    Dim intIndex As Integer				'loop counter, corresponds index (position) of each item
    Dim intCurrentType As Integer		'type for current item
    Dim strCurrentLabel As String		'label for current item

    Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
	Set objItems = objOutputDoc.Items
	 'GetDesignatedOutputDoc is a method that returns the designated output
	 'document. After objOutputDoc is set to the designated output document,
	 'the Items method is used to access the items in that document.

	intCount = objItems.Count 	'Count method returns the number
						 		'of output items in the designated document

    objOutputDoc.ClearSelection			'Clear any existing selections to avoid deleting
    									'output items that happen to be selected before
	    								'the script is run.

	For intIndex = 0 To intCount - 1
	 'The loop repeats as many times as there are output items.
	 'The intIndex variable is used as a counter. intCount is the total
	 'number of items. Output items are numbered sequentially starting
	 'at 0. Thus if there are 9 output items they have index values from 0 to 8.

		Set objItem = objItems.GetItem(intIndex)
        'Get the item whose position corresponds the current index value

        intCurrentType = objItem.SPSSType		'Returns type of current item
        objItem.Current = True

		 'The first line below checks whether the current item matches
		 'the type to be deleted. If yes, then get the label of the current
		 'item and check that also. If the label matches (or is empty)
		 'then select the item.

        If intCurrentType = intType Then
            strCurrentLabel = objItem.Label
            If strCurrentLabel = strLabel Or strLabel = "" Then
                objItem.Selected = True
             End If
        End If
    Next

	objOutputDoc.Remove		'Delete all items selected by the FOR... NEXT loop above.

End Sub