Hi forum, I've got this script that worked fine in SPSS 15.0 but it doesn't seem to function properly in 19
The idea of the script is to find all pivot tables in the currently opened Output screen, activate them and then apply a table look (via a user pointing at the .STT or in 15.0 a .TLO file) and then rotate the inner column labels before deactivating the table. I am for some reason unable to run this script from the menu -> Run script as it comes up saying WBB processor has encountered a problem, but it works fine when I load the .SBS file from the file-> open -> scripts dialogue. The other thing is it now only applies the code to the items that I have highlighted, whereas in 15.0 it was every pivot table. So can anyone help me understand what I've done wrong and how to fix it? Here's the code: Sub Main On Error GoTo Bye ' Variable Declaration ' For an undertermined reason scripts cannot be executed throught the Utilites -> Run scripts menu, ' Instead they must be opened like a script file and ran from the SPSS 19 Scripting page. Dim objOutputDoc As ISpssOutputDoc 'Declares the Output variable Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc 'Assigns currently active output to Output variable Dim strAppPath As String Dim objOutputItems As ISpssItems 'variable defining every item in the current output window Dim objOutputItem As ISpssItem 'variable defining the current item Dim objPivotTable As PivotTable Dim intCount As Integer 'declare the variable that will store the number of instances Dim varStrLook As String Set objOutputItems=objOutputDoc.Items Dim i As Integer 'for loops we need an INT variable that will be counted against the number of instances 'i' is standard notation ' Find out SPSS Directory strAppPath = objSpssApp.GetSPSSPath ' Select TableLook ' Old line they used a dollarsign after the getfilepath varStrLook = GetFilePath$("*.stt","stt",strAppPath,"Select TableLook and confirm with Save",4) 'New line is compatable with the new version of SPSS varStrLook = GetFilePath("*.stt","stt",strAppPath,"Select Tablelook and confirm with Save.",4) ' Tested re-applying the dollar sign, cofusingly removing or adding the Dollar sign ($) ' seems to have no affect, which is a little worrying at best. ' If Cancel selected or wrong file type then exit script If (Len(varStrLook)= 0) Or (Right(varStrLook,3)<>"stt") Then Exit Sub End If ' Loop which assigns a new TableLook to all existing Tables. ' hmmm something might have gone wrong here. intCount = objOutputItems.Count For i = 0 To intCount-1 Set objOutputItem=objOutputItems.GetItem(i) If objOutputItem.SPSSType=SPSSPivot Then Set objPivotTable=objOutputItem.ActivateTable objPivotTable.TableLook = varStrLook objPivotTable.RotateColumnLabels=True objOutputItem.Deactivate End If Next '******************************************************** 'Updated script from Version 15 -> 'Script now includes inner column label rotation '******************************************************** Bye: End Sub "Lo there do I see my father. Lo there do I see my mother and my sisters and my brothers. Lo there do I see the line of my people, back to the beginning. Lo, they do call to me, they bid me take my place among them, in the Halls of Valhalla, where the brave may live...forever." |
Hi, There are some incompatibilities after upgrading. Check out p. 408 of this document: ftp://public.dhe.ibm.com/software/analytics/spss/documentation/statistics/20.0/en/client/Manuals/IBM_SPSS_Statistics_Core_System_Users_Guide.pdf Regards, Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Free forum by Nabble | Edit this page |