Print to a printer other than the default one

im printing some pdf files and no matter what printer I select it always prints to the default one. This is the code...

If Me.PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

                Dim printername As String = Me.PrintDialog1.PrinterSettings.PrinterName
                For Each row As DataGridViewRow In dgv_Invoices.Rows

                    If row.Cells("Selected").Value = True Then

                        Dim filename As String = row.Cells("File").Value
                        Dim proc As New Process
                        Dim startInfo As New ProcessStartInfo(filename)

                        startInfo.FileName = filename
                        startInfo.Arguments = " " & Chr(34) & printername & Chr(34)
                        startInfo.WindowStyle = ProcessWindowStyle.Hidden
                        startInfo.Verb = "print"
                        proc.StartInfo = startInfo
                        row.Cells("Status").Value = "Printed"

                    End If

            End If

Any ideas on this??
Thanks experts!
Who is Participating?
Red-KingConnect With a Mentor IT ManagerCommented:
I've used the Application.ActivePrinter property in the past to do this.
I'm not sure you can use it outside of MS Office vb scripts but you could give it a try.

In my script I have;
Sub PrintZebra1()

    ActivePrinter = "Zebra TLP2824"
    With Options
        .UpdateFieldsAtPrint = False
        .UpdateLinksAtPrint = False
        .DefaultTray = "Use printer settings"
        .PrintBackground = True
        .PrintProperties = False
        .PrintFieldCodes = False
        .PrintComments = False
        .PrintHiddenText = False
        .PrintXMLTag = False
        .PrintDrawingObjects = True
        .PrintDraft = False
        .PrintReverse = False
        .MapPaperSize = False
        .PrintOddPagesInAscendingOrder = False
        .PrintEvenPagesInAscendingOrder = False
        .PrintBackgrounds = False
    End With
    With ActiveDocument
        .PrintPostScriptOverText = False
        .PrintFormsData = False
    End With

    Application.PrintOut Filename:="", Range:=wdPrintCurrentPage, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
        ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _

End Sub

Open in new window

You use the name displayed within the Printer Properties when setting the ActivePrinter property as far as I recall.
Here's the reference from the Office Dev Center

Éric MoreauSenior .Net ConsultantCommented:
I wrote an article a while back to show how to change the default printer:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.