Sub Main 'Title: ChangeLabelTitle.sbs 'Author: Michael Wexler, mailto:wexler at yahoo.com 'Purpose: Change the Title and Label of the last run procedure 'Assumptions: there is an open Output Doc (Navigator) 'Effects: Walks up the output tree to the Label and Title, and changes both of them. ' Used to label output for notes such as "filtered men" or "ignoring missing values" Or other ' notes 'Inputs: Text to be used as Label and Title 'Return Values: none 'Called as: SCRIPT file="c:\\my documents\\ChangeLabelTitle.sbs" ("Freq of Men only") . ' Notes: Headings and their Labels appear only in the tree. Titles, Labels/Content ' appear in both the output and the tree. Confusing, eh? ' From the SPSSType Property help file: ' Note that headings are "2" (SPSSHead)and only their label can be changed, appear ' only in the tree. ' Titles are "9" (SPSSTitle) and their label and content can be changed, appear In ' output and tree. ' Also, note that if the SPSS procedure errors out (typo in a variable Name, whatever), ' this program cannot detect this and will change the Wrong Item! ' 'Get the Viewer window and make it visible so we can see the title after we change it. Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc objOutputDoc.Visible = True Dim strParam As String strParam = objSpssApp.ScriptParameter(0) 'Get Output Items collection Set objOutputItems = objOutputDoc.Items() Dim intItemCount As Integer 'Number of output items. Dim intItemType As Integer 'Output item type. Dim strItemTitle As String 'The title text we want to find and change. Dim objSpssText As Object 'Grab the last created things title by walking backwards up the tree ' til we find a Title intItemCount = objOutputItems.Count For Index = intItemCount - 1 To 0 Step -1 Set objOutputItem = objOutputItems.GetItem(Index) intItemType = objOutputItem.SPSSType If intItemType = SPSSTitle And objOutputItem.Level=2 Then 'Debug.Print intItemType & " Should equal " & SPSSTitle Set objSpssText = objOutputItem.Activate objSpssText.Text = strParam objOutputItem.Deactivate objOutputItem.Label=Left(strParam, 35) 'So, if weve found the Title, then we can go up one and find the Heading 'Ok, now change the top one... Index=Index-1 Set objOutputItem = objOutputItems.GetItem(Index) objOutputItem.Label=Left(strParam, 35) Exit For End If Next End Sub