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

    <FONT face="Courier New">


    <SPAN><o:p> </o:p></SPAN>

    <SPAN>I’m using ActiveReports 2 in VB 6.<SPAN>  </SPAN>I’m trying to export report pages into separate pdf files.<SPAN>  </SPAN>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.<SPAN>  </SPAN>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.<o:p></o:p></SPAN>

    <SPAN><o:p> </o:p></SPAN>

    <SPAN>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, <SPAN> </SPAN>I get the error: 2147467259 – Automation error<SPAN>  </SPAN>Unspecified error. (I get this error when I step through the code).<SPAN>  </SPAN>Or I get the error: Error: -2147467259 – Method ‘Export’ of object ‘arRptCombine’ failed.<o:p></o:p></SPAN>

    <SPAN><o:p> </o:p></SPAN>

    <SPAN>If I run the report first, it will export just fine, but my pages are blank unless I commit the pages first.<SPAN>  </SPAN><o:p></o:p></SPAN>

    <SPAN><o:p> </o:p></SPAN>

    <SPAN>If I commit the pages, run the report and then export it, I get the same errors as above.<o:p></o:p></SPAN>

    <SPAN><o:p> </o:p></SPAN>

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


    <SPAN><SPAN>    </SPAN>Dim oPDF As ARExportPDF<o:p></o:p></SPAN>

    <SPAN><SPAN>    </SPAN>Dim rptCombinedSplit As arRptCombine</SPAN>

    <SPAN>    Dim intIndex as Integer</SPAN><SPAN><o:p>            </o:p></SPAN>

    <SPAN><o:p> </o:p></SPAN>

    <SPAN><SPAN>    </SPAN>Set rptCombinedSplit = New arRptCombine<o:p></o:p></SPAN>

    <SPAN><o:p> </o:p></SPAN>

    <SPAN><SPAN>    </SPAN>Set oPDF = New ARExportPDF<o:p></o:p></SPAN>

    <SPAN><SPAN>    </SPAN>oPDF.FileName = "C:\Data\test.pdf"<o:p></o:p></SPAN>

    <SPAN><o:p> </o:p></SPAN>

    <SPAN><SPAN>    </SPAN>Do Until intIndex > rptCombined.Pages.Count - 1<o:p></o:p></SPAN>

    <SPAN><SPAN>        </SPAN>rptCombinedSplit.Pages.Insert 0, rptCombined.Pages.item(intIndex)<o:p></o:p></SPAN>

    <SPAN><SPAN>            </SPAN>rptCombinedSplit.Pages.Commit<o:p></o:p></SPAN>

    <SPAN><SPAN>            </SPAN>rptCombinedSplit.Run False<o:p></o:p></SPAN>

    <SPAN><SPAN>            </SPAN>rptCombinedSplit.Export oPDF<o:p></o:p></SPAN>

    <SPAN><SPAN>       </SPAN><SPAN> </SPAN>intIndex = intIndex + 1<o:p></o:p></SPAN>

    <SPAN><SPAN>        </SPAN>Set rptCombinedSplit = Nothing<o:p></o:p></SPAN>

    <SPAN><SPAN>        </SPAN>Set rptCombinedSplit = New arRptCombine<o:p></o:p></SPAN>

    <SPAN><SPAN>    </SPAN>Loop<o:p></o:p></SPAN>


    <SPAN><o:p> </o:p></SPAN>

    <SPAN><FONT face=Arial>Is it not possible to split and export a temporary report?</FONT></SPAN>

    <SPAN><FONT face=Arial></FONT></SPAN> 

    <SPAN><FONT face=Arial>Thanks,</FONT></SPAN>

    <SPAN><FONT face=Arial>April</FONT></SPAN>

  • 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.

    <FONT face="Courier New">For intIndex = 0 to rptCombined.Pages.Count - 1</FONT><FONT face="Courier New"><O:P>     </O:P></FONT>

    <FONT face="Courier New"><O:P>        Set rptCombinedSplit = New arRptCombine </O:P></FONT>

    <SPAN><FONT face="Courier New"><SPAN>        </SPAN>rptCombinedSplit.Pages.Insert 0, rptCombined.Pages.item(intIndex)<O:P></O:P></FONT></SPAN>

    <SPAN><FONT face="Courier New"><SPAN>        </SPAN>rptCombinedSplit.Pages.Commit<O:P></O:P></FONT></SPAN>

    <SPAN><FONT face="Courier New"><SPAN>        '</SPAN>rptCombinedSplit.Run False<O:P></O:P></FONT></SPAN>

    <SPAN><FONT face="Courier New"><SPAN>        </SPAN>oPDF.Export rptCombinedSplit.Pages</FONT></SPAN>

    <SPAN><FONT face="Courier New"><O:P>Next intIndex</O:P></FONT></SPAN>

  • 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