Date: Fri, 4 Mar 2005 08:42:02 +0100
Reply-To: Pere-Joan Ventura <pjventura@gmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Pere-Joan Ventura <pjventura@gmail.com>
Subject: Re: Export to word
In-Reply-To: <BAY5-DAV104171954674923F9D4D3CBF5B0@phx.gbl>
Content-Type: text/plain; charset=US-ASCII
Thanks a lot,
I'm working with a basic descriptive study so the order of the pivot
tables and graphs into the SPSS Output is important for me.
Yesterday I was working in a Visual Basic module for Ms Word (XP
version) that allows me import all the pivot tables, graphs and text
into word. This visual basic module perform a copy-paste procedure
that maintains the order of the objects of SPSS output. In other
words, it works as the Export Pivot Tables to Word2.sbs script.
Suggestions on the VB are wellcome.
The VB module starts here.
-------------------------------------------------------------------------------------------------------------------------
Attribute VB_Name = "CopyPasteSPSSDoc"
Sub CopyPasteSPSS()
' Requirements:
' SPSS output ans Ms Word document must be open
' The Sax basic and the SPSS references must be activated
Dim objSpssApp As ISpssApp
Dim objOutputDoc As ISpssOutputDoc
Dim objItems As ISpssItems
Dim objItem As ISpssItem
Dim objPivotTable As PivotTable
Dim num_items As Integer
Set objSpssApp = GetObject(, "SPSS.Application")
Set objOutputDoc = objSpssApp.GetDesignatedOutputDoc
Set objItems = objOutputDoc.Items
num_items = objItems.Count
For i = 1 To num_items - 1
'Object selection
Set objItem = objItems.GetItem(i)
'Determining the SPSS object type
If objItem.SPSSType = SPSSText Then
objItem.Selected = True
'Copy the object
objOutputDoc.Copy
objItem.Selected = False
' Paste into word
Selection.PasteSpecial Link:=False, DataType:=wdPasteRTF, _
Placement:=wdInLine, DisplayAsIcon:=False
Selection.TypeParagraph
Selection.TypeParagraph
ElseIf objItem.SPSSType = SPSSPivot Then
objItem.Selected = True
'Copy the object
objOutputDoc.Copy
objItem.Selected = False
' Paste into word
Selection.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False
Selection.TypeParagraph
Selection.TypeParagraph
ElseIf objItem.SPSSType = SPSSChart Then
objItem.Selected = True
'Copy the object
objOutputDoc.Copy
objItem.Selected = False
' Paste into word
Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
Selection.TypeParagraph
Selection.TypeParagraph
End If
Set objItem = Nothing
Next i
End Sub
-------------------------------------------------------------------------------------------------------------------------
The VB module ends here.
Regards
--
Pere-Joan Ventura