NAV2009 classic - have used the classic method used by many - in codeunit having a printerselection by name and when job is done then restore the printer.
IN Windows 10 - the selected printer (spec. PDF printer) then becomes the default printer and stays there until you manually alter it in the control panel.
Testing with Windows 7 this is not the case - the original default printer stays as the default.
Cannot figure out why - anybody having an idea?
0
Answers
Normally you create a single instance codeunit - set the alternative printer there and then get the alternative printer in CU 1 and skip the printer selection one time. Also you have to reset the saved printer in the single instance cu.
Then you have a changed printer for a single print job!
Robert's Dynamics NAV Blog - Vom NAV Entwickler für NAV (Navision) Interessierte
SelectPrinterByName("User ID" : Code[20];"Report ID" : Integer;"Printer Name" : Text[30])
PrinterTable.SETFILTER(Name, '@' + "Printer Name", "Printer Name");
IF PrinterTable.FIND('-') THEN
BEGIN
//Store old selection.
PrinterRestoreUserID := "User ID";
PrinterRestoreReportID := "Report ID";
IF PrinterSelection.GET("User ID", "Report ID") THEN
BEGIN
PrinterRestorePrinterName := PrinterSelection."Printer Name";
BoolInsert := FALSE;
END ELSE
BEGIN
PrinterRestorePrinterName := '';
PrinterSelection.INIT;
PrinterSelection."User ID" := "User ID";
PrinterSelection."Report ID" := "Report ID";
BoolInsert := TRUE;
END;
PrinterSelection."Printer Name" := PrinterTable.ID;
IF BoolInsert THEN
PrinterSelection.INSERT
ELSE
PrinterSelection.MODIFY;
END ELSE
BEGIN
ERROR(STRSUBSTNO(Text033, "Printer Name"));
END;
And then the restore part:
RestorePrinterSelection()
IF PrinterRestorePrinterName <> '' THEN
BEGIN
IF PrinterSelection.GET(PrinterRestoreUserID, PrinterRestoreReportID) THEN
BEGIN
PrinterSelection."Printer Name" := PrinterRestorePrinterName;
PrinterSelection.MODIFY;
END;
END ELSE
BEGIN
IF PrinterSelection.GET(PrinterRestoreUserID, PrinterRestoreReportID) THEN
BEGIN
PrinterSelection.DELETE();
END;
END;
Actually, this could be regarded as an incompatibility between NAV and Windows 10. The automatic default printer switch should only work if the user manually selects a different printer, in my opinion.