0 Replies Latest reply on Dec 3, 2010 12:11 PM by DNAunion

    ShellExecute(..., "PrintTo", ...) and .GRP file type

    DNAunion

      I am trying to maintain some code that I did not write.  Stepping through the code I found that it is the following line that is causing the problem.

       

      ShellExecute(0, "Printto", "C:\USERS\me\TEMP\2\exportpdf.pdf", "ImagingPrinter", 0, 0)

       

      It is returning a value > 32, indicating success.

       

       

      That command is executed twice (not back to back: there is intervening code) with the exact same syntax both times.

       

      1) The first call takes the C:\USERS\me\TEMP\2\exportpdf.pdf file (which contains the body of a report) and "prints it" to the output folder as \\SOMESERVER\OutputFolder\FullReport.pdf.

       

      2) The second call is, best I can tell, supposed to take the contents of the updated C:\USERS\me\TEMP\2\exportpdf.pdf file (which now contains just a last page of a report) and append them to the end of the preexisting FullReport.pdf file in the output directory.

       

      Concerning the second call, though, before ShellExecute() executes there is a PDF file named FullReport.pdf in the output folder: it contains the body of the report.  However, after that one line of code (ShellExecute()) finishes executing, there is no longer a file by that name, but there is a file named Item2.grp.  The lack of a file named Item2.pdf is an error and a messagebox informs the user of failure.

       

       

       

      ---------------------------------------

      EDITED TO ADD:

       

      I found that the ShellExecute(..., "PrintTo", ...) call causes Windows to search the Registry for a "PrintTo" shell command for Adobe. That command is:

      “C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe” /t “%1” “%2” “%3” “%4”

      Where "%1" is the file name and "%2" is the printer name (and /t indicates "silent print": no visible Adobe window and no user intervention)

       

      Therefore, the overall Adobe call -- ShellExecute(..., "PrintTo", ...) -- translates into the following pseudocode:

      C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe

          “SilentPrint”

          “FileToPrint = C:\USERS\me\TEMP\2\exportpdf.pdf”         

           “OutputDirectory = \\SOMESERVER\OutputFolder; OutputFileName = FullReport.PDF”

       

      Hope that helps.

       

      Although I can see now how that line creates the output file, I still do not know why the existing .PDF disappears and a .GRP file appears.