vb .net Print without print Dialog

Vasiliki Konstanti 1 Reputation point
2022-12-20T10:04:11.63+00:00

i am trying to Print the currently active Document BUT i dont want the PrintDialog to pop-Up and i want to define my own Default printing Settings. Is there a way to that?

i tried using :

ActiveDocument.PrintOut(
Background:=True,
Append:=False,
Range:=Word.WdPrintOutRange.wdPrintAllDocument,
Item:=Word.WdPrintOutItem.wdPrintDocumentContent,
Copies:="3",
Pages:="1-3",
PageType:=Word.WdPrintOutPages.wdPrintAllPages,
PrintToFile:=False,
Collate:=True,
ManualDuplexPrint:=False)
And:

'PrintOut()

And

Application.Dialogs(Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFilePrint).Execute()
but there dont quite exactly deal with my problem.
(vb .net Print Active Document without PrintDialog and set new default settings for printer)

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,539 questions
Windows Server Printing
Windows Server Printing
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Printing: Printer centralized deployment and management, scan and fax resources management, and document services
637 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 43,996 Reputation points
    2022-12-21T08:56:37.06+00:00

    Hi,

    Thank you for posting your query.

    Kindly follow the steps provided below to resolve your issue.

    Dim m_PrintDocument = New Printing.PrintDocument

    Dim printControl = New Printing.StandardPrintController

    m_PrintDocument.PrintController = printControl

    m_PrintDocument.Print()

    It will Work fine. It will not Display PrintDialog, it send the print Directly to the printer.

    Go to this link for your reference and other troubleshooting procedures https://social.msdn.microsoft.com/Forums/vstudio/en-US/f8688005-cd30-49b8-826c-3fc5d597abb8/how-to-hide-print-dialog-while-printing-a-document-from-vbnet-application-?forum=vsto

    Do not hesitate to message us if you need further assistance.

    If the answer is helpful kindly click "Accept as Answer" and up vote it.


  2. Jiachen Li-MSFT 25,526 Reputation points Microsoft Vendor
    2022-12-23T08:59:02.76+00:00

    Hi @Vasiliki Konstanti ,
    You can use Document.PrintOut() method to print the current document.
    Set parameters for the Document.PrintOut() method to achieve the print you want.
    For more details about the parameters, you can refer to the following links.
    How to: Programmatically print documents
    Document.PrintOut method (Word)
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.