LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2005)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 19 Aug 2005 10:23:33 -0400
Reply-To:     thennig@idirect.com
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Timothy Hennigar <thennig@idirect.com>
Organization: Timothy Hennigar
Subject:      Another way (Sax Basic)
Content-Type: text/plain; charset="us-ascii"

Okay - since I failed to get a response to the TOC post lets try this another way .

I have a Sax Basic script that cycles through all visible pivot tables in the designated output window

I can pull the Pivot table title and attached a string ('Table') and counter (1 to say 100) and print

that to a text file to get a numbered listing of all of the Pivot tables in the output .

I can also use a variable to change the label of the pivot table IN THE NAVIGATOR part of the output

BUT I CANT SEEM TO CHANGE THE ACTUAL PIVOT TABLE TITLE --- any help here - the script is

below.

Option Explicit

'

Sub MAIN

'

' Starting from scratch with my own programming

' RUNS ON SINGLE TABLE OUTPUT FILE CALLED BY SYNTAX AT END OF TABLE RUN

' Modified Date: January 31, 2005

'

'DECLARATIONS

Dim objSpssApp As Object 'SPSS Application

Dim objSpssOpt As ISpssOptions 'SPSS Options

Dim objSpssDoc As ISpssDocuments 'SPSS Documents

Dim objSpssDat As ISpssDataDoc 'SPSS Data Doc

Dim objSpssSyn As ISpssSyntaxDoc 'SPSS Syntax Doc

Dim objSpssOut As ISpssOutputDoc 'SPSS Output Doc

Dim objSpssPrn As ISpssPrintOptions 'SPSS Print Options

Dim objSpssOut1 As ISpssItems 'SPSS Syntax Navigator Tree

Dim objSpssOut2 As ISpssItem 'SPSS Syntax Navigator Tree Item

Dim objPivotTable As PivotTable 'Pivot table

Dim FileExt2 As String 'output extension

FileExt2=".spo"

Dim FileToSave As String 'complete name of file to save

Dim TOCFile As String 'complete name of table of contents file

Dim ItmIndx As Integer 'item counter

Dim GenIndx As Integer 'index counter

Dim ItmType As Integer 'item type

Dim tblcntr As Integer 'table counter

Dim NewLabel As String 'replacement table title

'run from the open SPSS application

Set objSpssApp = GetObject(,"SPSS.Application")

Set objSpssOpt = objSpssApp.Options

'get the designated output window

Set objSpssOut = objSpssApp.GetDesignatedOutputDoc

'open TOC File

Open "CurrentTOC.txt" For Output As #1

tblcntr = 1

Wait 2

'THIS WORKS FINE TO CREATE MY LIST OF PIVOT TABLES

'collect and label table titles and write to file

Set objSpssOut1 = objSpssOut.Items

ItmIndx = objSpssOut1.Count

For GenIndx = 0 To (ItmIndx - 1) Step 1

Set objSpssOut2 = objSpssOut1.GetItem(GenIndx)

ItmType = objSpssOut2.SPSSType

If ((ItmType = 5) And (objSpssOut2.Visible)) Then

objSpssOut2.Selected=True

Print #1, "Table ";tblcntr;", ";objSpssOut2.Label

tblcntr = tblcntr + 1

objSpssOut2.Selected=False

End If

Next GenIndx

Wait 2

'I TRIED THIS - IT CHANGES THE PIVOT TABLE TITLE IN NAVIGATOR (LEFT WINDOW)

'BUT NOT ACUTAL PIVOT TABLE (RIGHT WINDOW)

'collect and label and change table titles and write to file

'Set objSpssOut1 = objSpssOut.Items

'ItmIndx = objSpssOut1.Count

'For GenIndx = 0 To (ItmIndx - 1) Step 1

' Set objSpssOut2 = objSpssOut1.GetItem(GenIndx)

' ItmType = objSpssOut2.SPSSType

' If ((ItmType = 5) And (objSpssOut2.Visible)) Then

' objSpssOut2.Selected=True

' Print #1, "Table ";tblcntr;", ";objSpssOut2.Label

' 'four new lines to try to change table title

' NewLabel = "Table " & tblcntr & ":" & objSpssOut2.Label

' objSpssOut2.Activate

' objSpssOut2.Label = NewLabel

' objSpssOut2.Deactivate

' tblcntr = tblcntr + 1

' objSpssOut2.Selected=False

' End If

'Next GenIndx

'Wait 2

'close TOC File

Close #1

Wait 2

'save designated output window to file of same name as the syntax

FileToSave = GetFilePath$ (,"sps","FIND Output FILE MATCH",0) & FileExt2

objSpssOut.SaveAs(FileToSave)

TOCFile = FileToSave & "TOC.txt"

Name "CurrentTOC.txt" As TOCFile

Wait 2

End Sub


Back to: Top of message | Previous page | Main SPSSX-L page