BusinessObjects Board

Sequential page numbers for entire pdf

Hi there

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.


sime (BOB member since 2002-08-22)

[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]


promero (BOB member since 2002-10-08)

Thanks promero! Nice code. :smiley:

I’ve combined your code with Integra’s FilterAndExport code so that I can automatically filter, renumber and then create multiple pdfs.


sime (BOB member since 2002-08-22)

Hi

I’ve tried using this code and it works, but once I save the report and open it again the report wont open. I am using 6.5.

Anyone know where I’m going wrong?


sward01 :ireland: (BOB member since 2005-12-19)

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(" &amp; i &amp; ")" 
    DocumentVariables.Add "=0", VarName 
    With DocumentVariables(VarName) 
        .Formula = "=Page() + " &amp; 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
vbasic code for pages.doc (29.0 KB)


smcpike (BOB member since 2002-10-25)

Here is a link where solution is provided with report!


KhoushikTTT :us: (BOB member since 2005-02-24)

Is there a way to do this without using VBA, ie with a variable/formula of some sort?


dkrauseuf (BOB member since 2007-02-06)

Thanks for the code above. It does exactly what it says it does.

However, when I run the report it opens on the last report instead of the first. This means my users don’t see page 1 first.

Does anyone know how to resolve this?


cook_jaime (BOB member since 2008-06-19)

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?


wettsten (BOB member since 2009-07-24)

Hi,

I have the same problem it’s perfectly working in DeskI but not in infoview.

Does anyone get an explanation ?

Regards.


pemasure (BOB member since 2011-10-25)

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…


wettsten (BOB member since 2009-07-24)