' Add a footnote to every Pivot Table in the viewer ' Raynald Levesque 2004/03/18 Option Explicit ' Change next line as required Const cFOOTNOTE="Weighted by weight1" Sub Main 'Add same footnote to every Pivot Table. Dim objOutputDoc As ISpssOutputDoc Dim objOutputItems As ISpssItems Dim objOutputItem As ISpssItem Dim objPivotTable As PivotTable Dim intCount As Integer Dim IntItem As Integer Dim I As Integer Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc Set objOutputItems=objOutputDoc.Items ' Get each pivot table For IntItem = 0 To objOutputItems.Count - 1 Set objOutputItem = objOutputItems.GetItem (IntItem) If objOutputItem.SPSSType = SPSSPivot Then Set objPivotTable = objOutputItem.ActivateTable Call InsertFootnote(objPivotTable,cFOOTNOTE) objOutputItem.Deactivate End If Next IntItem End Sub Sub InsertFootnote (objTable As PivotTable , strFootnote As String ) ' Insert a footnote at bottom of currently activated Pivot Table Dim objDataCells As ISpssDataCells Dim objFootnotes As ISpssFootnotes Set objDataCells=objTable.DataCellArray Set objFootnotes=objTable.FootnotesArray objTable.UpdateScreen=False objDataCells.SelectCellAt (0,0) objTable.InsertFootnote(strFootnote) objTable.ClearSelection objFootnotes.ChangeMarkerToSpecial (0, " ") 'Now we select the footnotes to perform some cosmetic changes objTable.SelectAllFootnotes 'Decrease the footnote size objTable.TextSize= 7 'Left justify the footnotes objTable.HAlign=0 '0 SpssHAlLeft (Left) '1 SpssHAlRight (Right) '2 SpssHAlCenter (Center) 'Maintain the font style of footnotes objTable.TextStyle=0 '0 SpssTSRegular (Regular) '1 SpssTSItalic (Italic) '2 SpssTSBold (Bold) '3 SpssTSBoldItalic (Bold Italic) objTable.UpdateScreen= True End Sub