I'm using Active Reports within my VB program to generate a report based on my data. Right now I have the report opening fine and it is allowing the user to print, copy, find, etc. I am unsure how to add the functionality to let the user choose to export the chart once the program is running.
I've been looking at many tutorials but there is always something that makes it unable to work in my program. For example this forum gives the exact code for what I want as they add an export button to the toolbar and then adds the functionality to the button. Unfortunately I am unable to access the toolbar. They access it with Me.Toolbar
and I am unable to access it this way.
Another forum here doesn't add the export to the toolbar and instead inserts it directly into the code but I'm not sure what to import to allow me to do it this way as my project doesn't recognize ActiveReportsPDFExport.ARExportPDF
.
UPDATE:
Found a way to export to PDF by adding to the ActiveReport in the design format a DataDynamics.ActiveReports.Export.Pdf.PdfExport
and then calling from my code PdfExport1.Export(Me.Document, "D:\Kyra\HELP.pdf")
Problem:
Below is the code to add a PDF Export button to the ActiveReports Toolbar using VB.NET and ActiveReports 6:
Const pdfExportToolID As Long = 42
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myExportTool As DataDynamics.ActiveReports.Toolbar.Button
myExportTool = New DataDynamics.ActiveReports.Toolbar.Button()
myExportTool.ButtonStyle = DataDynamics.ActiveReports.Toolbar.ButtonStyle.Text
myExportTool.Caption = "Export to PDF"
myExportTool.Id = pdfExportToolID
Me.Viewer1.Toolbar.Tools.Add(myExportTool)
' load report:
Dim rpt As New NewActiveReport1()
Me.Viewer1.Document = rpt.Document
rpt.Run(False)
End Sub
Private Sub Viewer1_ToolClick(ByVal sender As System.Object, ByVal e As DataDynamics.ActiveReports.Toolbar.ToolClickEventArgs) Handles Viewer1.ToolClick
If (e.Tool.Id = pdfExportToolID) Then
Dim pdf As New DataDynamics.ActiveReports.Export.Pdf.PdfExport()
pdf.Export(Me.Viewer1.Document, "C:\users\scott\junk\myActiveReport.pdf")
End If
End Sub
This code works inside of a form with an ActiveReports Viewer on hte form named "Viewer1".
Hope this helps,
Scott Willeke
GrapeCity