Exporting Report Pages to separate PDF files using a temporary report

Posted by: aprilda on 4 August 2017, 2:47 pm EST

  • Posted 4 August 2017, 2:47 pm EST


    Hello,


     


    I’m using ActiveReports 2 in VB 6.  I’m trying to export report pages into separate pdf files.  I’m doing this by creating a temporary report and adding the pages I need to export and then exporting the temporary report. The problem is that the main report containing the pages to export is also a temporary report with pages inserted from other reports.  I can get the export to work fine if I copy pages from one of the original reports, but not when I copy from my combined temporary report.


     


    When I copy from the temporary report, I can open it in the viewer just fine but if I try to export the report to pdf without running the report first,  I get the error: 2147467259 – Automation error  Unspecified error. (I get this error when I step through the code).  Or I get the error: Error: -2147467259 – Method ‘Export’ of object ‘arRptCombine’ failed.


     


    If I run the report first, it will export just fine, but my pages are blank unless I commit the pages first. 


     


    If I commit the pages, run the report and then export it, I get the same errors as above.


     


    Here is the code I’ve been testing with.  This is after the combined report is already created and contains pages from various reports.  Now I want to split those pages into separate pdf files.


    ========================


        Dim oPDF As ARExportPDF


        Dim rptCombinedSplit As arRptCombine


        Dim intIndex as Integer            


     


        Set rptCombinedSplit = New arRptCombine


     


        Set oPDF = New ARExportPDF


        oPDF.FileName = "C:\Data\test.pdf"


     


        Do Until intIndex > rptCombined.Pages.Count - 1


            rptCombinedSplit.Pages.Insert 0, rptCombined.Pages.item(intIndex)


                rptCombinedSplit.Pages.Commit


                rptCombinedSplit.Run False


                rptCombinedSplit.Export oPDF


            intIndex = intIndex + 1


            Set rptCombinedSplit = Nothing


            Set rptCombinedSplit = New arRptCombine


        Loop


    ========================


     


    Is it not possible to split and export a temporary report?


     


    Thanks,


    April

  • Replied 4 August 2017, 2:47 pm EST

    What version of ActiveReports are you using? Does your pdf export dll match?


    You could try using the export method of the pdf object instead of the report, I haven't experimented to know if there is a difference, but for some reason I've always used the export method off the export object and haven't had trouble.


    For intIndex = 0 to rptCombined.Pages.Count - 1     


            Set rptCombinedSplit = New arRptCombine 


            rptCombinedSplit.Pages.Insert 0, rptCombined.Pages.item(intIndex)


            rptCombinedSplit.Pages.Commit


            'rptCombinedSplit.Run False


            oPDF.Export rptCombinedSplit.Pages


    Next intIndex

  • Replied 4 August 2017, 2:47 pm EST

    Thank you very much.  The problem was in my dll versions.  I had lost my hard drive a couple of weeks ago and had to reinstall everything from scratch.  So I must have mixed up some of the service packs.  It works perfectly now. 

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels