Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you give VBA Code to save each report as PDF

Status
Not open for further replies.

rrbo

Programmer
Joined
May 7, 2003
Messages
24
Location
US
Dear All,

I have a Document that contains four reports like
Report(1)
Report(2)
Report(3)
Report(4)

I can save whole document as PDF and
also Active Report Tab as PDf,
But i wanna save each report tab from BO Document as a separate PDF using VBA.

Can you Please give me the sample code for this.

Save whole Document to PDF:

Sub ExportPDF()

Dim curdoc As Document
Dim currpt As Report
Set curdoc = ActiveDocument
Set currpt = ActiveReport

curdoc.ExportAsPDF ("C:\Test")

End Sub

Save Active Tab to PDf :
Sub ExportPDF()
ThisDocument.ActiveReport.ExportAsPDF ("C:\Test")
End Sub

Can you anybody please give me the sample code to save each report tab as separate PDF using VBA.

Thanks
 
I got the Answer for

To save as all report tabs as PDF :

Sub ExportPDF()
Dim rep As Report
Dim num_of_reps As Integer
Dim rep_name As String
Dim rep_path As String
Dim str As String
Dim ndate As String
Dim app1 As Application

Set app1 = Application
app1.Interactive = False
app1.BreakOnVBAError = False

'Count the number of reports
num_of_reps = ActiveDocument.Reports.Count

str = "Your path goes here"

For i = 1 To num_of_reps
Set rep = ActiveDocument.Reports.Item(i)
rep_name = rep.Name
rep_path = str & rep.Name
Call rep.ExportAsPDF(rep_path)
Next i
End Sub


Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top