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
 

'SPSS AnswerNet: Result 

'Solution ID:  100006374 
'Product:  SPSS Base  
'Version:  8.0 

'Title:
'Hiding a column such As "Frequency" In PivotTable Output 

'Description:
'Q. 
'I am using SPSS 8.0 For Windows And I don't want the column labelled "Frequency" 
'To be In my frequency tables. Is there a script which will hide this 
'column? 

'A. 
'The subroutine HideColumnLabelColumn will search For a Text String (such As "Frequency") 
'In column labels. When it finds the requested label, it shrinks the width of the column 
'To one point, which causes the column To become hidden. 

'To Call HideColumn from an autoscript routine: 
'The subroutine HideColumn will search For a Text String (such As paste the subroutine 
'HideColumn into your Autoscript.sbs file (at the End Is fine), Right-click On the table, Choose 
'Create/Edit Autoscript, And To the subroutine which the cursor Is placed In, add 

'Dim objPivot As PivotTable 
'Set objPivot = objTable 
'HideColumn objPivot, "Frequency" 

'Check the Edit->Options Dialog's Script tab, to be sure that the 
'routine Is enabled: there should be a check In the CheckBox In front of 
'the routine's name. 

'Here Is how the modified autoscript routine might look: 
_______________________________________________________ 

Sub Frequencies_Table_Frequencies_Create(objTable As Object, _ 
objOutputDoc As Object, lngIndex As Long) 
'Autoscript 
'Trigger Event: Frequencies Table Creation after running Frequencies 
procedure. 

'Effects: Goes through the Row Labels and finds "Total" rows 
'and turns "Total" and associated data cells bold 
Dim bolSelection As Boolean 

Call SelectRowLabelsAndData(objTable, cTOTAL, bolSelection) 
If bolSelection = True Then 
objTable.TextStyle = 2 'make text bold 
End If 

'--- this part was added to hide columns labelled "Frequency" --- 
Dim objPivot As PivotTable 
Set objPivot = objTable 
HideColumn objPivot, "Frequency" 
End Sub 

'_______________________________________________________ 

'The following Is a simple demonstration of how To Call HideColumn from 
'another routine. It can be applied To every PivotTable In the Output; 
'see the SPSS Script eXchange at 

'http://www.spss.com/software/spss/base/Win75/SCPTXCHG.html 

'For further examples. Save the Text below To a script named 
'"HideColumn.SBS" Select a pivot table, And Then run the script. 
_______________________________________________________ 

'********** Demo of HideColumn ********** 
'--- save everything below to a file "HideColumn.SBS" 
' select a pivot table and run the script 
Sub Main 
Dim objPivot As PivotTable 
Dim objItem As ISpssItem 

Dim bolFoundOutput As Boolean, bolFoundPivot As Boolean 

GetFirstSelectedPivot objPivot, objItem, _ 
bolFoundOutput, bolFoundPivot 
	If Not (bolFoundOutput And bolFoundPivot) Then 
	Exit Sub 
	End If 

HideColumn objPivot, "Frequency" 
objItem.Deactivate 
End Sub 

'********** To use in an Autoscript ********** 
'--- paste everything below into Autoscript.sbs --- 
'HideColumn searches for the requested label, and hides the 
'column in which it is found. Call HideColumn from another 
'routine. 
Sub HideColumn (objPivot As PivotTable, strLabel As String) 
Dim objColLabels As ISpssLabels 
Dim i As Integer, j As Integer 

Set objColLabels = objPivot.ColumnLabelArray 
With objColLabels 
	For i = .NumRows - 1 To 0 Step -1 
		For j = 0 To .NumColumns - 1 
			If Not IsNull(.ValueAt(i,j)) Then 
				If .ValueAt(i,j) = strLabel Then 
				objPivot.UpdateScreen = False 
				'make a column width less than 15 to hide 
				.ColumnLabelWidthAt(i,j) = 1 
				objPivot.UpdateScreen = True 
				'Exit Sub 
				End If 
			End If 
		Next 
	Next 
End With 
End Sub