Right now, I am hard coding the report tab names in my macro while generating a PDF file, Is it possible to read the value from a particular cell and tab page in a report?
Example:
[edit by Eileen to add BBCode]
doc.Reports.Item(2).Activate
Set rep = doc.ActiveReport
rep.Name = "1.Total Client Value Summary"
doc.Reports.Item(3).Activate
Set rep = doc.ActiveReport
rep.Name = "2.Client Value Detail by Product"
etc..
You can read the name of a tab page, but not a cell (that I know of)… I got around this once by creating variables with the information I needed… The variable started with the file extension wanted for the Save As (PDF, TXT, etc) and the variable “formula” was the name of the report tabs to be saved out.
There’s a resolution on the Knowledge Base if you have access to it. This resolution is for VBA. What we found was that with VBA you can save all of the tabs into one PDF. With JSP you can only save them out at separate PDFs.
Here’s the other topic where we discussed some of the issues and resolutions.
Sorry for being not clear in my question. I want to export the BO report(with some 14 tabs) as one pdf file. if I don’t hard code the report names like I mentioned above, the Bookmarks of the PDF file will be just 1,2,3…14.
So, my question is, Is it possible to read the names of the each tab page? I have all the names of the tab pages, in the HOME tab page in 14 different cells! If I can read each cell of the HOME tab page, my work will be done!
Dim boDoc As Document
Dim boRpts As Reports
Dim boRpt As Report
Dim x As Integer
Dim RptName(100) As String
Set boDoc = ActiveDocument
Set boRpts = boDoc.Reports
For x = 1 To boRpts.Count
Set boRpt = boRpts.Item(x)
RptName(x) = boRpt.Name
Next x
That’ll store up to 100 report (tab) names for you in the RptName array…
This seems to be a good solution. But, let me understand this…
If there are 14 tab pages, there will be 14 variables to retrieve the tab page names…
So, Again, I need to mention each variable in my macro, right? I cannot keep them in a loop…
Ignore my variable suggestion earlier. All the names will be within your macro as RptName(#)… You can refer to them later in the code with another loop if you need.
Nothing. You can’t read a cell (that I know of). You could create a variable and put that in the cell and then read the formula of the variable, but you can’t read a cell.
But isn’t that point moot if you are just trying to get the report tab names??
:? I’m sorry, txamara… I don’t understand what the issue is. By using the loop you have a small amount of code that will give you all the report (tab) names in your macro. I don’t know what else to say to help you. I’m sorry.
Why can’t you use the report name showing up in the report tab (then you would include your code ONCE within the For…Next loop)? Why do you have to reference a cell?
For Example:
Dim boDoc As Document
Dim boRpts As Reports
Dim boRpt As Report
Dim x As Integer
Dim RptName(100) As String
Set boDoc = ActiveDocument
Set boRpts = boDoc.Reports
For x = 1 To boRpts.Count
Set boRpt = boRpts.Item(x)
RptName(x) = boRpt.Name
Include your code for report here (exporting to PDF or whatever)
Next x
Sub RepPDFGenerate(doc As busobj.Document, ByVal Filename As String, NodeID As String, NodeName As String)
Dim rep As Report
Dim x As Boolean
Dim n As Integer
Call CheckDir(Filename)
doc.Reports.Item(1).Activate
Filename = Filename & (999999999 - NodeID) & "\default"
Set rep = doc.ActiveReport
doc.Reports.Item(2).Activate
Set rep = doc.ActiveReport
rep.Name = "1.Client Value Monthly and by Product"
doc.Reports.Item(3).Activate
Set rep = doc.ActiveReport
rep.Name = "2.Client Value by Person Business Unit and by Office"
doc.Reports.Item(4).Activate
Set rep = doc.ActiveReport
rep.Name = "3.Overall Top 30 Clients by Month"
doc.Reports.Item(5).Activate
Set rep = doc.ActiveReport
rep.Name = "4 Top 30 Clients across Product"
doc.Reports.Item(6).Activate
Set rep = doc.ActiveReport
rep.Name = "5. Top 30 Clients by Salesperson"
doc.Reports.Item(7).Activate
Set rep = doc.ActiveReport
rep.Name = "6. Top 30 Clients for Specific Product"
doc.Reports.Item(8).Activate
Set rep = doc.ActiveReport
rep.Name = "7. Client Value by Salesperson Monthly and by Product"
doc.Reports.Item(9).Activate
Set rep = doc.ActiveReport
rep.Name = "8. Individual Salesperson Report"
doc.ExportAsPDF (Filename)
log1.LogIt "Document saved as " & Filename & ""
doc.Reports.Item(2).Activate
Set rep = doc.ActiveReport
rep.Name = "1"
doc.Reports.Item(3).Activate
Set rep = doc.ActiveReport
rep.Name = "2"
doc.Reports.Item(4).Activate
Set rep = doc.ActiveReport
rep.Name = "3"
doc.Reports.Item(5).Activate
Set rep = doc.ActiveReport
rep.Name = "4"
doc.Reports.Item(6).Activate
Set rep = doc.ActiveReport
rep.Name = "5"
doc.Reports.Item(7).Activate
Set rep = doc.ActiveReport
rep.Name = "6"
doc.Reports.Item(8).Activate
Set rep = doc.ActiveReport
rep.Name = "7"
doc.Reports.Item(9).Activate
Set rep = doc.ActiveReport
rep.Name = "8"
doc.Reports.Item(1).Activate
Set rep = doc.ActiveReport
log1.LogIt ""
log1.LogIt "Tab saved as " & Filename & ", for: " & NodeName
End Sub
The problem is our report tab pages are named as 1,2,3,4,5,6,7 and 8. The actual names of the report tabs are in 8 individual cells, in the HOME tab page. As there is no way to read the cell, I am hard coding like the code shown above. I want to minimize the coding…
Not easy answer: Create a variable for each report name… So the variable Rpt Name 1 has the formula 1.Client Value Monthly and by Product. Then you can read in the values of those variables and use those in the code.