Return to the technote repository Choose the printer
at runtime

Introduction

A Frequently Asked Question is : how do I choose dynamically the printer ?

Magic has 2 ways to choose the printer :

  • Use PDlg (printer dialog) in the I/O Table, so the Windows print dialog will let you choose the printer. But you can't specify the default printer.
  • Define a Magic printer for each printer you use, or left the print name blank, so the print will go to the default printer.

[MAGIC_PRINTERS]Printer

Instead of defining several Magic printers, define only one printer, Printer for instance, and use it each time you want to print.

To change the printer, do an INIPUT ('[MAGIC_PRINTERS]Printer = '&RTRIM (A)&',,,60') where A is a string that contains the printer name (it's the name you find in the printer folder), or that remains blank to print to the default printer. A is the only parameter in the line that is useful for Windows printing.

You can set up a file, that for example associates a specific edition to a printer, and choose the printer at runtime, without user interaction

Download

Download this quick sample, that uses GET.DLL to list printers.