View Full Version : Restoring the previous Printer


xcrx
09-30-2010, 09:10 AM
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

boblarson
09-30-2010, 09:13 AM
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:


' 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)

xcrx
09-30-2010, 09:16 AM
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

xcrx
09-30-2010, 09:49 AM
Worked great. Thanks for the help.