User Guide
640
Chapter 46
Example: Getting the First Pivot Table
This script gets the first pivot table in the designated output document and activates it.
Sub Main
Dim objOutpu
tDoc As ISpssOutputDoc 'declare object variables
Dim objOutputItems As ISpssItems
Dim objOutputItem As ISpssItem
Dim objPivot
Table As PivotTable
Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc'get reference to designated output doc
Set objOutput
Items = objOutputDoc.Items()'get collection of items in doc
Dim intItemCount As Integer'number of output items
Dim intItemTy
pe As Integer'type of item (defined by SpssType property)
intItemCount = objOutputItems.Count()'get number of output items
For index = 0 To i
ntItemCount'loop through output items
Set objOutputItem = objOutputItems.GetItem(index)'get current item
intItemType = objOutputItem.SPSSType()'get type of current item
If intItemType
= SPSSPivot Then
Set objPivotTable = objOutputItem.Activate()'if item is a pivot table, activate it
Exit For
End If
Next index
End sub
Examples are also available in the online Help.Youcantrythemyourselfbypasting
the code from Help into the script window.