Set default printer via COM


#1

Hi All,
many years ago I think I used something like this to temporarily set PDFCreator as defaultPrinter and change it back aftewards:

DefaultPrinter := PDFCreator.cDefaultPrinter;
PDFCreator.cDefaultPrinter := 'PDFCreator';
PDFCreator.cPrinterStop := FALSE;

// Dynamics Nav statement to run and print a report to the system default printer
REPORT.RUNMODAL(reportNr, FALSE, TRUE);

PDFCreator.cDefaultPrinter := DefaultPrinter;
PDFCreator.cClose;

I cannot seem to find a way to set and restore the default printer with COM version > 2.0, however. Anyone has any tips?
Thanks in advance!


#2

Hi,

while PDFCreator doesn't provide this function anymore, there is most likely an alternative way of setting this in your code.
Which language are you using? It might have some native functions/wrappers to handle Windows printers.

Best regards

Robin


#3

I'm intergrating this into the Dynamics NAV Classic Client using C/AL: There's no way to directly set the default printer but I can handle this with a bit of additional C/AL Code for selecting the correct printers. But I liked that old feature very much :slight_smile:
Thanks for clarificiation!