1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'To insert a page break before PivotTables whose /TITLE starts with '/Page break'.
'The script is called by syntax using
'SCRIPT 'path\\script name.sbs'.
'Raynald Levesque 2002/05/22
'http://pages.infinit.net/rlevesqu/index.htm

Sub Main
        PageBreak True
End Sub

Sub PageBreak(blnBreak As Boolean)
    Dim i As Long
    Dim objItem As ISpssItem
	Dim objPivotTable As PivotTable
	Dim intPos As Integer

    With objSpssApp.GetDesignatedOutputDoc.Items
        For i = 0 To .Count - 1
            Set objItem = .GetItem(i)

			intPos = InStr(LCase(objItem.Label),"/page break")
			If intPos >0 Then	'Page break is required
				'Remove the '/Page break' portion from the Output navigator label
				objItem.Label = Left(objItem.Label,intPos - 1) & Mid(objItem.Label,intPos + 11)

				Select Case objItem.SPSSType
					Case SPSSPivot		'Remove the '/Page break' portion from Table title
						Set objPivotTable = objItem.Activate()
						objPivotTable.TitleText =Mid(objPivotTable.TitleText,12)
					Case SPSSChart
						'do nothing (it is not possible to modify the chart's title using SaxBasic)
				End Select

				'Insert page break
	            objItem.PageBreak = blnBreak
	            objItem.Deactivate
            End If
        Next
    End With
	Set objItem = Nothing
End Sub