Windows 10 printerselection

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?

Answers

  • I dont know about the function, which you use, but if the windows standard printer is changed, then you doing something wrong.

    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!
  • mdPartnerNLmdPartnerNL Member Posts: 802
    What happens when you do this directly on the server?
  • The code looks like this - 2 funktions in codeunit to handle it (Select printer by name and RestorePrinterSelection:

    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;
  • vaprogvaprog Member Posts: 1,140
    edited 2016-05-12
    This is a Windows 10 feature. It can be turned off in Settings > Devices > Printers & Scanners > Let Windows manage my default printer

    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.
Sign In or Register to comment.