How to change the default printer that ATEasy uses for printing

Knowledge Base Article # Q200090

Read Prior Article Read Next Article
Summary How to change the default printer that ATEasy uses for printing
  
Login to rate article
The following example shows how to change the default printer used by ATEasy when printing using ALog.PrintLog method or internal functions such as LogPrint, FilePrint. The example prints the ALog control (log1) to a network printer:


Procedure btnPrint.OnClick(): Void Public Compile ! Occurs
! when the mouse button is pressed and released upon the object.
    sDefaultPrinter: String
    sPrinter: String
    ob: Object
{
    ! Example for Log Printing with printer different than default

    ! Use the following to print while prompting the user to select printer
    !log1.ExecWB(alogOleCmdIdPrint, alogOleCmdExecOptPromptUser)

    ! Use the following code to change the default printer
    ! (that ATEasy uses when printing) programmatically
    ! print to sPrinter to (may be different than current default)
    sPrinter="\\\\geoserver\\Dell Laser Printer 5100cn PCL6"
    ! Get current default printer
    ob=CreateObject("WScript.Shell")
    sDefaultPrinter=ob.RegRead("HKCU\\Software\\Microsoft\\Windows NT\\"
    "CurrentVersion\\Windows\\Device")
    sDefaultPrinter=Left(sDefaultPrinter, Pos(",", sDefaultPrinter))
    ! Set default printer
    ob=CreateObject("WScript.Network")
    ob.SetDefaultPrinter(sPrinter)
    ! Print
    log1.PrintLog()
    ! Restore default printer
    ob.SetDefaultPrinter(sDefaultPrinter)
    ob=Nothing
}
Article Date 5/29/2008
Keywords ATEasy, Printer, Log


Login to rate article

Read Prior Article Read Next Article