none
Two-side printing automation RRS feed

  • Question

  • Dear Hans,

    How can I built in my VB code the setting of two-side printing of several worksheets?

    Thank you in advance!

    Regards,

    Levente

    Friday, October 26, 2018 7:58 AM

Answers

  • Hi Levente1981,

    Sorry for the late reply.

    You can set up the printer using the printer name set in the Windows system.

    Please use the following code:

    Dim printer As New PrintDocument()
    
    printer.PrinterSettings.PrinterName = “HP Deskjet”

    For more information, please see the links as below:

    How to Print to a Specific Printer in VB.NET

    How can I specify a printer other than the default printer?

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.



    • Edited by Lina-MSFT Monday, October 29, 2018 6:23 AM
    • Marked as answer by Levente1981 Monday, October 29, 2018 1:40 PM
    Monday, October 29, 2018 6:21 AM

All replies

  • Hi Levente1981,

    >>How can I built in my VB code the setting of two-side printing of several worksheets?

    Please use the following code:

    Dim pr As New Printer
    Dim ps As New Printing.PrinterSettings
    If ps.CanDuplex = True Then
        pr.Duplex = vbPRDPVertical
    Else
        MsgBox("Duplex printing is not supported.")
    End If

    For more information, please refer the following links:

    Printer.Duplex Property

    Duplex Enum

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Friday, October 26, 2018 9:15 AM
  • Dear Lina,

    How should I modify the first row of code given in that case if I have several printers but there is marked only one  by default.

    Thanks in advance!

    Friday, October 26, 2018 9:31 AM
  • Hi Levente1981,

    Sorry for the late reply.

    You can set up the printer using the printer name set in the Windows system.

    Please use the following code:

    Dim printer As New PrintDocument()
    
    printer.PrinterSettings.PrinterName = “HP Deskjet”

    For more information, please see the links as below:

    How to Print to a Specific Printer in VB.NET

    How can I specify a printer other than the default printer?

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.



    • Edited by Lina-MSFT Monday, October 29, 2018 6:23 AM
    • Marked as answer by Levente1981 Monday, October 29, 2018 1:40 PM
    Monday, October 29, 2018 6:21 AM