views:

257

answers:

2

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:

  1. This is called at the end of my function which opens the active report. I want the user to be able to choose to export the report and then be given the option of choosing the format and location where they want to save the report to.
+2  A: 

Just follow along in the instructions here. Specifically, it's the button they add 'cmdExport' that lets the user start the export.

ho1
I added a button but I am unable to set the caption or the onClick event. The only event it is able to do is 'Disposed'
Kyra
I also tried http://www.datadynamics.com/Help/AR2Std/HX_Adding_Buttons_to_the_Viewer_Control.html but I am unable to find (in toolbox or to add to the toolbox) the ActiveX Viewer Control. I found code that can export, hypothetically, (Me.HtmlExport1.Export(rpt.Document, Application.StartupPath + "\\HTMLExpt.html"))) but I want it to be the users choice and not automatically. Additionally I found http://www.freevbcode.com/ShowCode.Asp?ID=1617 but I am unable to access the toolbar. When I go Me. the toolbar doesn't show up.
Kyra
@Kyra: Not sure if I understand, but when you've got the form open in the designer, just try doubleclicking on the button and it should add the click handler automatically.
ho1
I'm afraid that I don't know that much about ActiveReports, I only did very simple things quite a while ago so I'm not sure why you're having those problems.
ho1
@ho1 thanks for trying :)
Kyra
A: 

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
scott