I have a script I downloaded and modified a number of years ago and until recently it’s worked fine to remove tables I didn’t need from the output. It’s now generating an error – perhaps after installing version 25 on my machine – I’m unsure since I only use this script occasionally and haven’t used it in a while. The problem line is below. I’ve tried a modification based upon something I saw on the web, but that didn’t work. I’m good enough to modify these things, but not good enough to write something like this myself. Any ideas? …could this be something that a patch/fix to v25 might fix, or has something changed in spss to alter whether this line of code will work? The entire script is below the row of asterisks . ' Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc Set objOutputDoc = SpssClient.GetDesignatedOutputDoc() ********************** 'This script "cleans up" the designated output document by finding and deleting all Notes tables. 'Requirements: None 'SCRIPT TO REMOVE UNWANTED ITEMS FROM THE OUTPUT NAVIGATOR 'ASSUMPTIONS 'The document you want to clean is displayed in the Output Navigator 'and is the currently designated output document. Option Explicit 'All variables must be declarated before being used Sub Main 'The main procedure sets parameters to determine what 'output items get deleted, and then calls the 'SelectAndRemoveOutputItem procedure to do the real work. 'Declare variables for parameters Dim intType As Integer 'Type of output item to delete, expressed as an integer Dim strLabel As String 'Item label displayed in left pane of Output Navigator intType = SPSSNote 'Type to delete. See help on "SpssType property" for valid types 'strLabel = "Notes" 'Label to delete '******************************************************************** 'You can edit the above lines to delete items of a different type. 'See help on the SpssType property for the complete list of types. 'Labels are case-sensitive (meaning that "Case Processing Summary" 'is not the same as "case processing summary") 'For example, to delete all Case Processing Summaries, specify: 'intType = SpssPivot 'strLabel = "Case Processing Summary" '********************************************************************* Call SelectAndRemoveOutputItem(intType, strLabel) 'Call procedure below with specified parameters Call SelectAndRemoveOutputItem(SPSSPivot, "Case Processing Summary") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "Statistics") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "Model Summary") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "ANOVA") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "Variables Entered/Removed") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "Excluded Variables") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "Dependent Variable Encoding") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "Classification Table") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "Variables not in the Equation") 'I added this line Call SelectAndRemoveOutputItem(SPSSPivot, "Omnibus Tests of Model Coefficients") 'I added this line Call SelectAndRemoveOutputItem(SPSSHead, "Block 0: Beginning Block") 'I added this line Call SelectAndRemoveOutputItem(SPSSWarning, "Warnings" ) 'I added this line Call SelectAndRemoveOutputItem(SPSSLog, "Log") 'I added this line Call SelectAndRemoveOutputItem(SPSSTitle, "Title") 'I added this line Call SelectAndRemoveOutputItem(SPSSText, "Active Dataset") 'I added this line End Sub Sub SelectAndRemoveOutputItem(intType As Integer, Optional strLabel As Variant) 'This procedure iterates through output items and deletes all output 'items that match the specified search type and label. 'Variable declarations Dim objOutputDoc As ISpssOutputDoc Dim objItems As ISpssItems Dim objItem As ISpssItem 'By convention, object variable names begin With "obj". 'OutputDoc, ISpssItems, And ISpssItem are the names of SPSS object classes. 'For example, the first declaration above declares an object variable named '"objOutputDoc" and assigns it to the OutputDoc Object 'class. Below, that variable is set to the designated output document 'in order to access the items in that output document. Dim intCount As Integer 'total number of output items Dim intIndex As Integer 'loop counter, corresponds index (position) of each item Dim intCurrentType As Integer 'type for current item Dim strCurrentLabel As String 'label for current item Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc ' Set objOutputDoc = SpssClient.GetDesignatedOutputDoc() Set objItems = objOutputDoc.Items 'GetDesignatedOutputDoc is a method that returns the designated output 'document. After objOutputDoc is set to the designated output document, 'the Items method is used to access the items in that document. intCount = objItems.Count 'Count method returns the number 'of output items in the designated document objOutputDoc.ClearSelection 'Clear any existing selections to avoid deleting 'output items that happen to be selected before 'the script is run. For intIndex = 0 To intCount - 1 'The loop repeats as many times as there are output items. 'The intIndex variable is used as a counter. intCount is the total 'number of items. Output items are numbered sequentially starting 'at 0. Thus if there are 9 output items they have index values from 0 to 8. Set objItem = objItems.GetItem(intIndex) 'Get the item whose position corresponds the current index value intCurrentType = objItem.SPSSType 'Returns type of current item objItem.Current = True 'The first line below checks whether the current item matches 'the type to be deleted. If yes, then get the label of the current 'item and check that also. If the label matches (or is empty) 'then select the item. If intCurrentType = intType Then strCurrentLabel = objItem.Label If strCurrentLabel = strLabel Or strLabel = "" Then objItem.Selected = True End If End If Next objOutputDoc.Remove 'Delete all items selected by the FOR... NEXT loop above. End Sub |
I ran this script (after removing all the extraneous blank lines) without a problem using V25 with Fixpack 2. What was the error? On Wed, Feb 13, 2019 at 3:36 PM Jeff <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |