Change label title of last run procedure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 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 |
Related pages
...