the first snippet is what gets called from a button. I have 3 buttons, 1 for 11x17, 1 for C-Size and 1 for D-Size. These all make prints using the predefined setups.
the second does just a setup, no plot.
the third is the routine that actually does the work. It takes arguments from either the first or second snippet and applies as needed. 808 gets credit for helping me with this code.
Public Sub Vendor1117()
Call SetupAndPlot("11x17Draft.pc3", "11X17-CHECKSET.ctb", "ANSI_B_(11.00_x_17.00_Inches)", acScaleToFit, ac90degrees)
ThisDrawing.Plot.PlotToDevice
ThisDrawing.Close (True)
End Sub
Public Sub SetupVendor1117()
Call SetupAndPlot("11x17Draft.pc3", "11X17-CHECKSET.ctb", "ANSI_B_(11.00_x_17.00_Inches)", acScaleToFit, ac90degrees)
End Sub
Public Sub SetupAndPlot(ByRef Plotter As String, CTB As String, SIZE As String, PSCALE As String, ROT As String)
Dim Layout As AcadLayout
On Error GoTo Err_Control
Set Layout = ThisDrawing.ActiveLayout
Layout.RefreshPlotDeviceInfo
Layout.ConfigName = Plotter ' CALL PLOTTER
Layout.PlotType = acExtents
Layout.PlotRotation = ROT ' CALL ROTATION
Layout.StyleSheet = CTB ' CALL CTB FILE
Layout.PlotWithPlotStyles = True
Layout.PlotViewportBorders = False
Layout.PlotViewportsFirst = True
Layout.CanonicalMediaName = SIZE ' CALL SIZE
Layout.PaperUnits = acInches
Layout.StandardScale = PSCALE 'CALL PSCALE
Layout.ShowPlotStyles = False
ThisDrawing.Plot.NumberOfCopies = 1
Layout.CenterPlot = True
Layout.ScaleLineweights = False
ThisDrawing.Regen acAllViewports
ZoomExtents
Set Layout = Nothing
ThisDrawing.Save
Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
Case "-2145320861"
MsgBox "Unable to Save Drawing- " & Err.Description
Case "-2145386493"
MsgBox "Drawing is setup for Named Plot Styles." & (Chr(13)) & (Chr(13)) & "Run CONVERTPSTYLES command", vbCritical, "Change Plot Style"
Case Else
MsgBox "Unknown Error " & Err.Number
End Select
End Sub