Script to print crystal report to designated printer

SUGGESTED

Everything works on the script except for the line that calls for the print

oRpt.Printout

(I tried oRpt.Printout(FALSE) but then nothing happens at all)

The line actually technically works, but instead of just printing the the default printer, the printer diolog box pops up and asks for a printer selection.

When OK is pressed the report prints.

I would like to avoid this step and have the report print without additional input.

i would also like to specify the printer if say for example the label printer is not their default printer.

thanks in advanced

  • 0

    It's helpful to see the script so we can put your issue in context.

  • 0 in reply to BadgerJerry

    The code is as follows

    Path = "C:\Sage Software\V450\MAS90\Reports\1_VCI_label_CUSTOM.rpt"

    Set App = CreateObject("CrystalRuntime.Application")

    Set oSORpt = App.OpenReport(Path)

    Login = App.LogOnServerEx("p2sodbc.dll", "Sage 4.5", , , , ,"DSN="+ODBC+"; UID="+UID+"; PWD="+PWD+"; Directory="+Directory+"; Prefix="+Directory+"\SY\, "+Directory+"\==\; ViewDLL="+Directory+"\HOME; Company="+Company+"; LogFile=\PVXODBC.LOG; CacheSize=4; DirtyReads=1; BurstMode=1; StripTrailingSpaces=1; SERVER=NotTheServer")

    Set ParamFields = oSORpt.ParameterFields

    Set Serial = ParamFields.Item(1)

    Serial.SetCurrentValue(SerialNoIn)

    oSORpt.Printout

    The last line does print, but I am trying to print without having to select a printer.

    thanks

  • 0 in reply to mmchico

    The VBScript Crystal Report Wrapper has a setting to select a printer.  I haven't tried it, but here's the syntax:

    Rept.SelectPrinter cDriverName, cPrinterName, cPort

    Please post the solution back if you get it to work.

  • 0 in reply to BadgerJerry
    SUGGESTED

    WORKS!!!

    I had tried the line you mentioned (below) before and it was still prompting for a printer.

    oSOrpt.SelectPrinter cDriverName, cPrinterName, cPort

    I found that the .PrintOut line had to be set to NOT prompt by setting it to FALSE (see below)

    oSORpt.Printout(FALSE)

    Very slick script

    -A report was set up to print a label for a particular serial number.

    -A UDF was set up to read in a serial number

    -That serial number was then set as the report parameter and a label was automatically printed to the label printer.

    Now they can simply scan in the Serial number and the labels will print in one step.

  • 0
    SUGGESTED

    2023 Update, This script no longer works in Sage due to Crystal Reports no longer supporting (apparently not supported since Crystal Reports ver. 2012)

    Set App = CreateObject("CrystalRuntime.Application")

    You can run the workstation in MAS90 mode and install Crystal Reports, version 8 and make sure the Reports are written in Crystal Version 8. But this is poor practice.

    I was able to re-write the script for Sage 100 2022 utilizing

    oSession.GetObject("SY_ReportEngine")

    and its functions.

    SY_ReportEngine (sage.com)

    Once you look into the functions, it is quite slick. You can use Sage directly along with security, Pass variables, Define Printers, Number of Copies, print or even preview the report.