Removing objects out of SPSS Text

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Removing objects out of SPSS Text

Matthias Klein
Hello, gladly I found your list. I hope you can help me with a problem I
encountered.

I'm a programming novice. I never worked with SPSS syntax, Python or VBA.
Now I have to solve a problem which I don't really understand...I have to
remove textobjects from the SPSS output file. I searched everywhere (also
this list) but I couldn't find any solution.

What I've found was a code example on Raynald's SPSS Tools page. So I
started building code around it. The result was this script...but it
doesn't work right.

After starting the script with the SPSS script-launcher, it removes a few
lines an the standard header of the output file. Then it stops at line 40
(Set objText = Nothing), error message: Error in SPSS library. Why? The
declaration of objText is ok, isn't it? Why does it run for a little time
and then stops suddenly?

Fehler=error.

---------------------------------------------
'#Language "WWB-COM"

Option Explicit

Sub Main
 Dim objAusgabe As ISpssOutputDoc
 Dim objItem As ISpssItem
     Dim objItem2 As ISpssItem
 Dim objText As ISpssrtf
 Dim i As Long

On Error GoTo Fehler

 Set objAusgabe = objSpssApp.GetDesignatedOutputDoc

 For i = 0 To objAusgabe.Items.Count - 1
  Set objItem = objAusgabe.Items.GetItem(i)
  If objItem.SPSSType = SPSSPageTitle Then
   objItem.PageBreak = False
  End If
  If objItem.SPSSType = SPSSText Then
    Set objText = objItem.ActivateText
     If InStr(objText.Text, "Nummer") > 0 Then
      objText.Text= Mid$(objText.Text,260)
      End If
      If InStr(objText.Text, "no cases available")> 0
Or InStr(objText.Text, "DatenSet")>0 Or InStr(objText.Text, "r:\")> 0 Then
      objItem.Visible = False
     End If
      objItem.Deactivate
    End If
        If objItem.SPSSType = SPSSLog Then
       objItem.Visible = False
   End If
     Next

 Exit Sub

Fehler:
 MsgBox Err.Description, vbCritical, "Fehlermeldung"
 Set objText = Nothing
 Set objAusgabe = Nothing
 Set objItem = Nothing
    Set objItem2 = Nothing
End Sub
---------------------------------------------

I hope you can help me with my problem...

Yours mklein

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Automatic reply: Removing objects out of SPSS Text

Ling Ting
I am out of the office until June 2th. If you need immediate assistance please contact 479-575-2905.

Thank you.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD