'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