Restoring the previous Printer

xcrx

Edge
Local time
Today, 12:13
Joined
Oct 21, 2009
Messages
80
I wrote a shot app in VB.net that sends a file to a pdf printer. It works just fine however I have now installed it on the end users computer and his complaint is that if he wants to print the file after it is sent to the pdf printer, he has to select his printer from the menu.

When my App prints the file it changes the last used printer to the pdf printer. So what my question is, is there a way to switch the last used printer in VB.net without actually printing a file? Also if there is how would I go about saving the current printer before I change to the pdf printer?

I know it seems like it would be a lot easier just to pick the printer from the menu but this guy is very particular.

Any help is greatly appreciated.

Ryan
 
What is the code you are using to change to the PDF printer. You should be able to get the current printer and save that to a string.

In Access VBA it is this:

Code:
' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName
 ' set the printer
Set Application.Printer = Application.Printers("Adobe PDF")
 
' set it back
    Set Application.Printer = Application.Printers(strDefaultPrinter)
 
Last edited:
Code:
        Public Sub PrintDrawing()
            ' Set a reference to the print manager object of the active document.
            ' This will fail if a drawing document is not active.
            Dim oPrintMgr As DrawingPrintManager
            oPrintMgr = m_inventorApplication.ActiveDocument.PrintManager

            ' Get the name of the printer that will be used.
            Dim sPrinterName As String
            sPrinterName = "Bullzip PDF Printer"
            If sPrinterName = "" Then
                Exit Sub
            Else
                oPrintMgr.Printer = sPrinterName
            End If

            ' Set to print in color.
            oPrintMgr.ColorMode = PrintColorModeEnum.kPrintDefaultColorMode

            ' Set to print using Landscape orientation.
            oPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation

            ' Set the paper size.
            oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeLetter

            ' Set to print all sheets.
            oPrintMgr.PrintRange = PrintRangeEnum.kPrintAllSheets

            ' Set to print full scale.
            oPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale

            ' Submit the print.
            oPrintMgr.SubmitPrint()

            ' Change the number of copies to 1.
            oPrintMgr.NumberOfCopies = 1

That is the code I am currently using. I will try your tip and see what I get.

Thanks
Ryan
 

Users who are viewing this thread

Back
Top Bottom