"Viewer output to xls" problem

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

"Viewer output to xls" problem

Mario Giesel
Hello, SPSS fans,

I use SPSS 15 and have a SAX Basic script file that exports output tables into an xls file:

Sub Main
    Dim objOutputDoc As ISpssOutputDoc
    Dim objOutputItems As ISpssItems
    Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
    Set objOutputItems = objOutputDoc.Items
    objOutputDoc.SelectAllTables
    objOutputDoc.ExportDocument (SpssSelected, "H:\dialego-kunden\Bayer\3584_CorporateImageStudy_2012_International\Analysen\Makros\bayer2.xls", SpssFormatXls, False)
End Sub

The script is called by syntax via the SCRIPT command.

a) My main problem is that a message window opens and warns if the output file already exists. I don't want that.
It disturbs the process if I have to test a long series of tables that are to be exported into different files each.
b) I also forgot the command that clears the viewer after the export.

It's long ago since I dealt with SAX Basic. Maybe someone has a quick idea or can give me some reference offering help.
I could not find a Python way for this task in the internet - but maybe someone else knows a Python solution with SPSS 15?

Thanks for any comments,
 Mario
Mario Giesel
Munich, Germany
Reply | Threaded
Open this post in threaded view
|

Re: "Viewer output to xls" problem

Jon K Peck
You could do all this with Python, but there is no need to switch to do this.  The objSpssApp has an Alerts property.  Just put
objSpssApp = False
in your script.

The easiest way to clear the Viewer is just to close that window.  Running
OUTPUT CLOSE.
will dispose of the window.  It could also be closed with Basic syntax, or you could select all the objects and just remove them.

HTH,

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Mario Giesel <[hidden email]>
To:        [hidden email]
Date:        07/24/2012 11:09 AM
Subject:        [SPSSX-L] "Viewer output to xls" problem
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hello, SPSS fans,

I use SPSS 15 and have a SAX Basic script file that exports output tables into an xls file:

Sub Main
   Dim objOutputDoc As ISpssOutputDoc
   Dim objOutputItems As ISpssItems
   Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
   Set objOutputItems = objOutputDoc.Items
   objOutputDoc.SelectAllTables
   objOutputDoc.ExportDocument (SpssSelected, "H:\dialego-kunden\Bayer\3584_CorporateImageStudy_2012_International\Analysen\Makros\bayer2.xls", SpssFormatXls, False)
End Sub

The script is called by syntax via the SCRIPT command.

a) My main problem is that a message window opens and warns if the output file already exists. I don't want that.
It disturbs the process if I have to test a long series of tables that are to be exported into different files each.
b) I also forgot the command that clears the viewer after the export.

It's long ago since I dealt with SAX Basic. Maybe someone has a quick idea or can give me some reference offering help.
I could not find a Python way for this task in the internet - but maybe someone else knows a Python solution with SPSS 15?

Thanks for any comments,
Mario

Reply | Threaded
Open this post in threaded view
|

Re: "Viewer output to xls" problem

David Marso
Administrator
In reply to this post by Mario Giesel
Don't hardcode the file name!!

Mario Giesel wrote
Hello, SPSS fans,

I use SPSS 15 and have a SAX Basic script file that exports output tables into an xls file:

Sub Main
    Dim objOutputDoc As ISpssOutputDoc
    Dim objOutputItems As ISpssItems
    Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
    Set objOutputItems = objOutputDoc.Items
    objOutputDoc.SelectAllTables
    objOutputDoc.ExportDocument (SpssSelected, "H:\dialego-kunden\Bayer\3584_CorporateImageStudy_2012_International\Analysen\Makros\bayer2.xls", SpssFormatXls, False)
End Sub

The script is called by syntax via the SCRIPT command.

a) My main problem is that a message window opens and warns if the output file already exists. I don't want that.
It disturbs the process if I have to test a long series of tables that are to be exported into different files each.
b) I also forgot the command that clears the viewer after the export.

It's long ago since I dealt with SAX Basic. Maybe someone has a quick idea or can give me some reference offering help.
I could not find a Python way for this task in the internet - but maybe someone else knows a Python solution with SPSS 15?

Thanks for any comments,
 Mario
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: "Viewer output to xls" problem

Mario Giesel
In reply to this post by Jon K Peck
Thanks, Jon, this works well:

Sub Main
    Dim objOutputDoc As ISpssOutputDoc
    Dim objOutputItems As ISpssItems
    strParameter = objSpssApp.ScriptParameter(0)
    Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
    Set objOutputItems = objOutputDoc.Items
    objOutputDoc.SelectAllTables
    objSpssApp.Alerts = False
    filename= strParameter
    objOutputDoc.ExportDocument (SpssSelected, dateiname, SpssFormatXls, False)
End Sub

OUTPUT CLOSE *.
also does - thanks a lot!
 Mario


Von: Jon K Peck <[hidden email]>
An: [hidden email]
Gesendet: 19:17 Dienstag, 24.Juli 2012
Betreff: Re: "Viewer output to xls" problem

You could do all this with Python, but there is no need to switch to do this.  The objSpssApp has an Alerts property.  Just put
objSpssApp = False
in your script.

The easiest way to clear the Viewer is just to close that window.  Running
OUTPUT CLOSE.
will dispose of the window.  It could also be closed with Basic syntax, or you could select all the objects and just remove them.

HTH,

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Mario Giesel <[hidden email]>
To:        [hidden email]
Date:        07/24/2012 11:09 AM
Subject:        [SPSSX-L] "Viewer output to xls" problem
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hello, SPSS fans,

I use SPSS 15 and have a SAX Basic script file that exports output tables into an xls file:

Sub Main
   Dim objOutputDoc As ISpssOutputDoc
   Dim objOutputItems As ISpssItems
   Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
   Set objOutputItems = objOutputDoc.Items
   objOutputDoc.SelectAllTables
   objOutputDoc.ExportDocument (SpssSelected, "H:\dialego-kunden\Bayer\3584_CorporateImageStudy_2012_International\Analysen\Makros\bayer2.xls", SpssFormatXls, False)
End Sub

The script is called by syntax via the SCRIPT command.

a) My main problem is that a message window opens and warns if the output file already exists. I don't want that.
It disturbs the process if I have to test a long series of tables that are to be exported into different files each.
b) I also forgot the command that clears the viewer after the export.

It's long ago since I dealt with SAX Basic. Maybe someone has a quick idea or can give me some reference offering help.
I could not find a Python way for this task in the internet - but maybe someone else knows a Python solution with SPSS 15?

Thanks for any comments,
Mario



Mario Giesel
Munich, Germany
Reply | Threaded
Open this post in threaded view
|

Re: "Viewer output to xls" problem

David Marso
Administrator
See Bolded elements in original.  I doubt that works as posted.
Here is a lean mean version.
Sub Main
    objSpssApp.Alerts = False
    With objSpssApp.GetDesignatedOutputDoc
            .SelectAllTables
    .ExportDocument ( SpssSelected, objSpssApp.ScriptParameter(0), SpssFormatXls,  False)
    End With
End Sub
---
Mario Giesel wrote
Thanks, Jon, this works well:


Sub Main
    Dim objOutputDoc As ISpssOutputDoc
    Dim objOutputItems As ISpssItems
    strParameter = objSpssApp.ScriptParameter(0)
    Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
    Set objOutputItems = objOutputDoc.Items
    objOutputDoc.SelectAllTables
    objSpssApp.Alerts = False
    filename= strParameter
    objOutputDoc.ExportDocument (SpssSelected, dateiname, SpssFormatXls, False)
End Sub

OUTPUT CLOSE *.
also does - thanks a lot!
 Mario




________________________________
 Von: Jon K Peck <[hidden email]>
An: [hidden email] 
Gesendet: 19:17 Dienstag, 24.Juli 2012
Betreff: Re: "Viewer output to xls" problem
 

You could do all this with Python, but
there is no need to switch to do this.  The objSpssApp has an Alerts
property.  Just put
objSpssApp = False
in your script.

The easiest way to clear the Viewer
is just to close that window.  Running  
OUTPUT CLOSE.
will dispose of the window.  It
could also be closed with Basic syntax, or you could select all the objects
and just remove them.

HTH,

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621
 



From:      
 Mario Giesel <[hidden email]>
To:      
 [hidden email] 
Date:      
 07/24/2012 11:09 AM
Subject:    
   [SPSSX-L] "Viewer
output to xls" problem
Sent by:    
   "SPSSX(r)
Discussion" <[hidden email]>
________________________________
 


Hello, SPSS fans,

I use SPSS 15 and have a SAX Basic script file that exports output tables
into an xls file:

Sub Main
   Dim objOutputDoc As ISpssOutputDoc
   Dim objOutputItems As ISpssItems
   Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
   Set objOutputItems = objOutputDoc.Items
   objOutputDoc.SelectAllTables
   objOutputDoc.ExportDocument (SpssSelected, "H:\dialego-kunden\Bayer\3584_CorporateImageStudy_2012_International\Analysen\Makros\bayer2.xls",
SpssFormatXls, False)
End Sub

The script is called by syntax via the SCRIPT command.

a) My main problem is that a message window opens and warns if the output
file already exists. I don't want that.
It disturbs the process if I have to test a long series of tables that
are to be exported into different files each.
b) I also forgot the command that clears the viewer after the export.

It's long ago since I dealt with SAX Basic. Maybe someone has a quick idea
or can give me some reference offering help.
I could not find a Python way for this task in the internet - but maybe
someone else knows a Python solution with SPSS 15?

Thanks for any comments,
Mario
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: "Viewer output to xls" problem

Mario Giesel
Thanks, David,
 I tried your lean solution and it perfectly worked. Meanwhile I found the command for clearing the output window: Remove
I think that's a bit quicker than "OUTPUT CLOSE *." when dealing with dozens of exports.

Sub Main
    objSpssApp.Alerts = False
    With objSpssApp.GetDesignatedOutputDoc
        .SelectAllTables
        .ExportDocument (SpssSelected, objSpssApp.ScriptParameter(0),SpssFormatXls,  False)
        .SelectAll
        .Remove
    End With
End Sub

Best wishes,
 Mario


Von: David Marso <[hidden email]>
An: [hidden email]
Gesendet: 17:03 Donnerstag, 26.Juli 2012
Betreff: Re: "Viewer output to xls" problem

See Bolded elements in original.  I doubt that works as posted.
Here is a lean mean version.
Sub Main
    objSpssApp.Alerts = False
    With objSpssApp.GetDesignatedOutputDoc
            .SelectAllTables
        .ExportDocument ( SpssSelected, objSpssApp.ScriptParameter(0),
SpssFormatXls,  False)
    End With
End Sub
---
Mario Giesel wrote

>
> Thanks, Jon, this works well:
>
>
> Sub Main
>     Dim objOutputDoc As ISpssOutputDoc
>  *   Dim objOutputItems As ISpssItems*
>     strParameter = objSpssApp.ScriptParameter(0)
>     Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
> *    Set objOutputItems = objOutputDoc.Items*
>     objOutputDoc.SelectAllTables
>     objSpssApp.Alerts = False
>     *filename*= strParameter
>     objOutputDoc.ExportDocument (SpssSelected,* dateiname*, SpssFormatXls,
> False)
> End Sub
>
> OUTPUT CLOSE *.
> also does - thanks a lot!
> Â Mario
>
>
>
>
> ________________________________
>  Von: Jon K Peck &lt;peck@.ibm&gt;
> An: SPSSX-L@.UGA
> Gesendet: 19:17 Dienstag, 24.Juli 2012
> Betreff: Re: "Viewer output to xls" problem
>
>
> You could do all this with Python, but
> there is no need to switch to do this. Â The objSpssApp has an Alerts
> property. Â Just put
> objSpssApp = False
> in your script.
>
> The easiest way to clear the Viewer
> is just to close that window. Â Running
> OUTPUT CLOSE.
> will dispose of the window. Â It
> could also be closed with Basic syntax, or you could select all the
> objects
> and just remove them.
>
> HTH,
>
> Jon Peck (no "h") aka Kim
> Senior Software Engineer, IBM
> peck@.ibm
> new phone: 720-342-5621
>
>
>
>
> From:     Â
> Â Mario Giesel &lt;spss.giesel@&gt;
> To:     Â
> Â SPSSX-L@.uga
> Date:     Â
> Â 07/24/2012 11:09 AM
> Subject:   Â
>    [SPSSX-L] "Viewer
> output to xls" problem
> Sent by:   Â
>    "SPSSX(r)
> Discussion" &lt;SPSSX-L@.uga&gt;
> ________________________________
>
>
>
> Hello, SPSS fans,
>
> I use SPSS 15 and have a SAX Basic script file that exports output tables
> into an xls file:
>
> Sub Main
>    Dim objOutputDoc As ISpssOutputDoc
>    Dim objOutputItems As ISpssItems
>    Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
>    Set objOutputItems = objOutputDoc.Items
>    objOutputDoc.SelectAllTables
>    objOutputDoc.ExportDocument (SpssSelected,
> "H:\dialego-kunden\Bayer\3584_CorporateImageStudy_2012_International\Analysen\Makros\bayer2.xls",
> SpssFormatXls, False)
> End Sub
>
> The script is called by syntax via the SCRIPT command.
>
> a) My main problem is that a message window opens and warns if the output
> file already exists. I don't want that.
> It disturbs the process if I have to test a long series of tables that
> are to be exported into different files each.
> b) I also forgot the command that clears the viewer after the export.
>
> It's long ago since I dealt with SAX Basic. Maybe someone has a quick idea
> or can give me some reference offering help.
> I could not find a Python way for this task in the internet - but maybe
> someone else knows a Python solution with SPSS 15?
>
> Thanks for any comments,
> Mario
>




--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Viewer-output-to-xls-problem-tp5714412p5714468.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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


Mario Giesel
Munich, Germany