Can I force page numbers to run sequentially across all report tabs? My aim is to produce a pdf that has sequential page numbering so that it can be published as a single report.
When I save as a pdf I see that Busobj outputs the Report tabs sequentially so that it becomes a single pdf - but the page numbering gives it away.
[list=1:f027ac6d0d]
[*:f027ac6d0d]Add the following code to the ThisDocument module of the document (Visual Basic Editor, ALT+F11).
Option Explicit
Private Sub Document_AfterRefresh()
RecountPages
End Sub
Private Sub RecountPages()
Dim i As Integer
Dim Pages As Integer
Dim VarName As String
On Error Resume Next
For i = 1 To Reports.Count
VarName = "Page(" & i & ")"
DocumentVariables.Add "=0", VarName
With DocumentVariables(VarName)
.Formula = "=Page() + " & Pages
.Qualification = boDetail
End With
Pages = Pages + Reports(i).NumberOfPages
Next i
For i = 1 To Reports.Count
Reports(i).ForceCompute
Next i
End Sub
[:f027ac6d0d]Refresh the document. Several new document variables will be created, one for each “tab” (report) in the document. These variables are called <Page(n)>, where n is the report number (1, 2, 3…).
[:f027ac6d0d]On each report, replace the =Page() expression you use with =<Page(n)>, where n is the report number.
[:f027ac6d0d]Save the document.[/list]
Then:[list][:f027ac6d0d]Each time the document is refreshed, the page expressions will be recalculated.
[:f027ac6d0d]If you add new reports, refresh the document to create new <Page(n)> variables, and use them in the new reports.
[:f027ac6d0d]If you remove reports, remove the unused <Page(n)> variables.
[*:f027ac6d0d]If you add, remove or reorder reports, you must adjust the n in each report.[/list]
This code posting earlier in this thread was great for my need to page number across the complete PDF. However, I did get some errors in BO 6.5 and had a coworker help me tweak it, the code below works great in BO 6.5 reports!
Option Explicit
Private Sub Document_AfterRefresh()
RecountPages
End Sub
Private Sub RecountPages()
Dim i As Integer
Dim Pages As Integer
Dim VarName As String
Dim Reports as Reports
On Error Resume Next
Set Reports = Applicaton.ActiveDocument.Reports
For i = 1 To Reports.Count
VarName = "Page(" & i & ")"
DocumentVariables.Add "=0", VarName
With DocumentVariables(VarName)
.Formula = "=Page() + " & Pages
.Qualification = boDetail
End With
Pages = Pages + Reports(i).NumberOfPages
Next i
For i = 1 To Reports.Count
Reports(i).ForceCompute
Next i
This code works perfectly for refreshing the document in DeskI (BO XI R2). I have a problem when I export it and try to use it in InfoView. This line in VBA causes an error:
Pages = Pages + Reports(i).NumberOfPages
Why does this property (NumberOfPages) work in DeskI and not in InfoView? I am logged in under Adminstrator so I don’t think I’m lacking a permission. Anyone have an alternative method to numbering the pages?
it is now nearly five years later and the same problem has come up. has anyone ever found a solution to this problem? a solution that doesn’t involve upgrading…