Public Sub PrintDrawing()
_InvApplication = _
Runtime.InteropServices.Marshal. _
GetActiveObject("Inventor.Application")
' assumes you have had Inventor application
' 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 = _InvApplication.ActiveDocument.PrintManager
' Get the name of the printer that will be used.
If MsgBox("Using printer """ & oPrintMgr.Printer &
""" Do you want to continue?",
vbYesNo + vbQuestion) = vbNo Then
' Change to another printer.
Dim sPrinterName As String
sPrinterName = InputBox(
"Enter name of new printer:", "New Printer")
If sPrinterName = "" Then
Exit Sub
Else
oPrintMgr.Printer = sPrinterName
End If
End If
' Set to print in color.
oPrintMgr.ColorMode =
PrintColorModeEnum.kPrintColorPalette
' Set to print two copies.
oPrintMgr.NumberOfCopies = 2
' Set to print using portrait orientation.
oPrintMgr.Orientation =
PrintOrientationEnum.kPortraitOrientation
' Set the paper size.
oPrintMgr.PaperSize =
PaperSizeEnum.kPaperSize11x17
' Set to print all sheets.
oPrintMgr.PrintRange =
PrintRangeEnum.kPrintAllSheets
' Set to print full scale.
oPrintMgr.ScaleMode =
PrintScaleModeEnum.kPrintFullScale
' Submit the print.
oPrintMgr.SubmitPrint()
' Change the number of copies to 1.
oPrintMgr.NumberOfCopies = 1
' Change the paper size to a custom size. The units are in centimeters.
oPrintMgr.PaperSize =
PaperSizeEnum.kPaperSizeCustom
oPrintMgr.PaperHeight = 15
oPrintMgr.PaperWidth = 10
' Get and set the current sheet range.
Dim iFromSheet As Long
Dim iToSheet As Long
Call oPrintMgr.GetSheetRange(
iFromSheet, iToSheet)
MsgBox("Current sheet range is " & iFromSheet &
" to " & iToSheet & Chr(13) & _
"Setting to print sheets 1-2.")
' Change the print range to print sheets 1 through 2.
oPrintMgr.PrintRange =
PrintRangeEnum.kPrintSheetRange
Call oPrintMgr.SetSheetRange(1, 2)
' Submit the print.
oPrintMgr.SubmitPrint()
End Sub