hexagon logo

Printreport

Hi!
Working on a little script to print pdf-reports. Is working well enough most of the time. One exception being that when ran multiple times the reports get appended to the existing file.

I use SetPrinterOptionsEx to set path and settings, using PCD_OVERWRITE as filemode. I print using the PrintReport method. Still it always gets appended. I've tried all the modes but it always appends.

Also when switching from for instance AUTO to OVERWRITE using the script it is changed correspondingly in the settings in the menu, however its still printed with the add indexnumbers from AUTO. I have to manually change it in the menu to something other than OVERWRITE and then back for the indexnumbers to go away.

First question, does printreport always use APPEND?

Second, why isn´t the printer settings updated properly by a call to SetPrinterEx? Do I need to do something else?

Is the any other way of doing this?

I guess I should be able to check if the file exists and delete before Printing, and check if the filename is wrong afterwards (due to switch from auto) and rename the file if needed. I would however really prefer not to if possible as it opens the possibilities of IO-exceptions...

Grateful for any input.
/L
Parents
  • Good lord that section of the automation language is not right!

    Buggy as ****, however this seems to work.

    I'm not sure why but it seems I need to refresh report twice (before and after setting the print options)

    Also (and I think this is what causes the appending, make sure you switch printing off again at the end)





    Sub main()

    Dim pcapp As Object
    Dim pcpart As Object
    Dim ew As Object
    Dim rw As Object

    Set pcapp = createobject("pcdlrn.application")
    Set pcpart = pcapp.activepartprogram


    Set rw = pcpart.reportwindow

    rw.FullReportMode

    rw.RefreshReport


    Set ew = pcpart.editwindow



    ew.SetPrintOptionsEx 2,0,3,0,"C:\Temp\Test123.pdf",1,0



    rw.RefreshReport

    rw.printreport

    ew.SetPrintOptionsEx 0,0,3,0,"C:\Temp\Test123.pdf",1,0

    End Sub
Reply
  • Good lord that section of the automation language is not right!

    Buggy as ****, however this seems to work.

    I'm not sure why but it seems I need to refresh report twice (before and after setting the print options)

    Also (and I think this is what causes the appending, make sure you switch printing off again at the end)





    Sub main()

    Dim pcapp As Object
    Dim pcpart As Object
    Dim ew As Object
    Dim rw As Object

    Set pcapp = createobject("pcdlrn.application")
    Set pcpart = pcapp.activepartprogram


    Set rw = pcpart.reportwindow

    rw.FullReportMode

    rw.RefreshReport


    Set ew = pcpart.editwindow



    ew.SetPrintOptionsEx 2,0,3,0,"C:\Temp\Test123.pdf",1,0



    rw.RefreshReport

    rw.printreport

    ew.SetPrintOptionsEx 0,0,3,0,"C:\Temp\Test123.pdf",1,0

    End Sub
Children
No Data