SPSS Pivot tables
John
Hendrickx
|
Attribute VB_Name = "SPSSTab"
Sub fixSPSS()
'SPSS pivot tables pasted from SPSS 8.0 to 10.05 into Microsoft Word
'print each row double. This macro fixes this by converting the table
'to text, then back to a table again. The "Simple1" autoformat is
'applied as well (change this to suit your tastes) and all columns
'except the first are right aligned.
'To use, place the cursor in the table, press alt-F8 and
'select "fixSPSS".
'An SPSS script "Export_to_Word_RTF.sbs" is also available at the SPSS
'site to export *all* SPSS pivot tables to Word.
If Not Selection.Information(wdWithInTable) Then
MsgBox prompt:="The cursor must be in a table" _
& vbCr & "before running the fixSPSS macro", _
Title:="fixSPSS error"
Exit Sub
End If
Selection.Tables(1).Select
With Selection
.Font.Reset
.Rows.ConvertToText
'standard formatting with simple1
.ConvertToTable AutoFit:=True, Format:=wdTableFormatSimple1, _
ApplyBorders:=True, ApplyShading:=True, ApplyFont:=True, _
ApplyColor:=True, ApplyHeadingRows:=True, ApplyLastRow:=False, _
ApplyFirstColumn:=True, ApplyLastColumn:=False
'uncomment this for no formatting, no borders
'.ConvertToTable AutoFit:=True, Format:=wdTableFormatSimple1, _
ApplyBorders:=False, ApplyShading:=False, ApplyFont:=False, _
ApplyColor:=False, ApplyHeadingRows:=False, ApplyLastRow:=False, _
ApplyFirstColumn:=False, ApplyLastColumn:=False
'right align all columns ...
.ParagraphFormat.Alignment = wdAlignParagraphRight
End With
'left align the first column
Selection.Columns(1).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
End Sub
InstallationUse the following steps to install the fixSPSS macro in Word:
UsagePaste the SPSS pivot table in Word, then place the cursor somewhere in the table. Run the macro by pressing alt-F8, then select fixSPSS. |