NEO,
Are you sure, you are calling the macro in after_refresh event.
The code will assign the value to the variables after refresh, for those variables which you said created same as tab names.
I would suggest assign zero(0) OR “”(double quotes) to the variables depending on the return type and try.
I created four tabs, as 1998, 1999, 2000 and All. Created four varibles named same as the Tabs
1998=Page()
1999=Page()
2000=Page()
All=Page()
VB editor (Alt F11), I wrote this code
Private Sub Document_AfterRefresh()
Call PageNumberTabs
End Sub
Sub PageNumberTabs()
PageNum = 0
For i = 1 To ActiveDocument.Reports.Count
If i <> 1 Then
DocumentVariables.Item(ActiveDocument.Reports.Item(i).Name).Formula = "= " & Chr(34) & "Page " & Chr(34) & " & FormatNumber (Page() + " & PageNum & ", ""#"")"
Else
DocumentVariables.Item(ActiveDocument.Reports.Item(i).Name).Formula = "= " & Chr(34) & "Page " & Chr(34) & " & FormatNumber (Page() , ""#"")"
End If
ActiveReport.ForceCompute
PageNum = PageNum + ActiveDocument.Reports(i).NumberOfPages
Next i
End Sub
This solution worked wonderfully. Thanks!
Can anyone suggest how to get the Page 1 of Page N in the same situation. Right now, its generating Page 1 to N , but i dont know how to get the total number of pages count and show it in all the reports.
I did try that. But my last report has multiple sheets. eg. my last report has pages 18, 19 and 20
And this one gives me 18 as the total pages and not 20
You probably don’t need this answer anymore, but for anyone else with the same question, you can add a line of code to the macro and it will insert the total number of pages into another variable. I called mine LastPage. Then you will just need to add & "of " & to your formulas and all will be fine.
Sub PageNumberTabs()
…(same code as posted earlier)…
PageNum = PageNum + ActiveDocument.Reports(i).NumberOfPages
Next i
'The following line is the one I added
DocumentVariables.Item("LastPage").Formula = PageNum
I’ve added your amendment to get the “page x of y” but it doesn’t seem to give me the right numbers.
I have a 3 tab, 13 page report
Tab 1 -Notes - 1 page
Tab 2 -Directorate - 2 pages
Tab 3 -Buyer - 9 pages
The pages sequentially number perfectly (thanks) although the final part giving the total number of pages is having problems.
i.e the second tab numbers, Page 2 of 4, Page 5 of 5… the thrid tab also has problems.
I have the VB as you have above, I created variables just like you did in your sample report and I have done the page numbers as you suggest.
You said you were expecting a result of 13, but didn’t say what result you were getting. I was pointing out that you might be expecting the wrong result. My post was meant to be helpful. I appologize if you didn’t take it that way.
I am trying to have the sequencial page number for the pdf files that comes from multiple webI reports in a PDF format using publication.
What are the options I have in WEBI.
I went through this post, I believe this solution is for DESKI.
if we have any possible solution for WebI, please let me know.
For first data provider, use: “1.” + Page()
For second data provider, use: “2.” + Page()
So, you will have Page Numbers like 1.1, 1.2, 2.1, 2.2, 2.3 etc. Of course, this only makes sense when each data provider gives you a different sub report (of the main report).
Fingers crossed for something in a later version but BO once again seem focused on expanding the product base (and renaming existing products) rather than strengthening what they have.