Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Print macro SW. User select papersize - papersize determine printer/plotter as defined in the macro source code

1,068 views
Skip to first unread message

Poul Berthelsen

unread,
Jun 6, 2001, 8:15:27 AM6/6/01
to
'Print macro SW. User select papersize - papersize determine printer/plotter
as defined in the macro source code

'Print macro - select papersize and, wow, - the drawing is printed
automatically on correct printer/plotter
'PSB/2001-05-28 Poul Johansen Machinery - DK-4540 Faarevejle
'The macro is epecially designed for use in the drawing area
'If the macro is used in assembly or part area , is it recommended to select
a wireframe for simple BW printing
'Assemblies and parts will be fitted to the selected papersize.

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Dim Paperformat As Variant 'defining paperformat
Dim Printer_no1 As Variant 'defining printer no. 1 (laserprinter)
Dim Printer_no2 As Variant 'defining printer no. 2 (plotter)
Dim A4 As Variant
Dim A3 As Variant
Dim A2 As Variant
Dim A1 As Variant
Dim A0 As Variant

Const swPrintPaperSize = 0
Const swPrintOrientation = 1
Const vbPRORPortrait = 1
Const vbPRORLandscape = 2

Sub print_selected_paperformat() 'macro created by PSB

Dim swApp As Object
Dim Part As Object
'Set printer path and name
Let Printer_no1 = "\\PJMEL\HPLJ4MV" 'printer path and name (laserprinter)
Let Printer_no2 = "\\PJMEL\HPDJ650" 'printer path and name (plotter)
'Set paperformats - take a look on the list in the bottom of macro
Let A4 = 9
Let A3 = 8
Let A2 = 54
Let A1 = 55
Let A0 = 56

Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc

'Apply the paperformat - user input!
Paperformat = InputBox("Enter paper size (only numbers: 5=FIT to A3,
4,3,2,1,0)", "Print macro for SolidWorks", "4") 'A4 to A0
'Select which subroutine to select
If Paperformat = 4 Then GoTo printformat_a4 Else
If Paperformat = 3 Then GoTo printformat_a3 Else
If Paperformat = 2 Then GoTo printformat_a2 Else
If Paperformat = 1 Then GoTo printformat_a1 Else
If Paperformat = 0 Then GoTo printformat_a0 Else
If Paperformat = 5 Then GoTo print_fit_a3 Else GoTo End_routine
End

'subroutines depending on papersize
printformat_a4:
Printer = Printer_no1
Part.PrintSetup(swPrintOrientation) = vbPRORPortrait
Let Paperformat = A4 '#9 = A4 on laserprinter HPLJ4MV
swApp.ActivePrinter = Printer
Part.PrintSetup(swPrintPaperSize) = Val(Paperformat) 'Enable selected
paperformat A4
GoTo Print_finally_drawing

printformat_a3:
Printer = Printer_no1
Part.PrintSetup(swPrintOrientation) = vbPRORLandscape
Let Paperformat = A3 '#8 = A3 on laserprinter HPLJ4MV
swApp.ActivePrinter = Printer
Part.PrintSetup(swPrintPaperSize) = Val(Paperformat) 'Enable selected
paperformat A3
GoTo Print_finally_drawing

printformat_a2:
Printer = Printer_no2
Part.PrintSetup(swPrintOrientation) = vbPRORPortrait
swApp.ActivePrinter = Printer
Let Paperformat = A2
Part.PrintSetup(swPrintPaperSize) = Val(Paperformat) 'Enable selected
paperformat A2
GoTo Print_finally_drawing

printformat_a1:
Printer = Printer_no2
Part.PrintSetup(swPrintOrientation) = vbPRORPortrait
swApp.ActivePrinter = Printer
Let Paperformat = A1
Part.PrintSetup(swPrintPaperSize) = Val(Paperformat) 'Enable selected
paperformat A1
GoTo Print_finally_drawing

printformat_a0:
Printer = Printer_no2
Part.PrintSetup(swPrintOrientation) = vbPRORPortrait
swApp.ActivePrinter = Printer
Let Paperformat = A0
Part.PrintSetup(swPrintPaperSize) = Val(Paperformat) 'Enable selected
paperformat A0
GoTo Print_finally_drawing

print_fit_a3:
Printer = Printer_no1
Part.PrintSetup(swPrintOrientation) = vbPRORLandscape
Let Paperformat = A3
swApp.ActivePrinter = Printer
Part.PrintSetup(swPrintPaperSize) = Val(Paperformat) 'Enable selected
paperformat A3
'Part.PrintPreview 'ONLY FOR TEST
Part.PrintOut2 1, 1, 1, False, Printer, 0#, False, ""
GoTo End_routine

Print_finally_drawing:
'Part.PrintPreview 'ONLY FOR TEST
Part.PrintOut2 1, 1, 1, False, Printer, 1#, False, ""
GoTo End_routine

End_routine:
End Sub

'Values for the PaperSize Member HPLJ4MV
'Value Paper size
'1 Letter (8.5 x 11 in.)
'2 Letter Small (8.5 x 11 in.)
'3 Tabloid (11 x 17 in.)
'4 Ledger (17 x 11 in.)
'5 Legal (8.5 x 14 in.)
'6 Statement (5.5 x 8.5 in.)
'7 Executive (7.25 x 10.5 in.)
'8 A3 (297 x 420 mm)
'9 A4 (210 x 297 mm)
'10 A4 Small (210 x 297 mm)
'11 A5 (148 x 210 mm)
'12 B4 (250 x 354 mm)
'13 B5 (182 x 257 mm)
'14 Folio (8.5 x 13 in.)
'15 Quarto (215 x 275 mm)
'16 11 x 17 in.
'18 Note (8.5 x 11 in.)
'19 Envelope #9 (3.875 x 8.875 in.)
'20 Envelope #10 (4.125 x 9.5 in.)
'21 Envelope #11 (4.5 x 10.375 in.)
'22 Envelope #12 (4.25 x 11 in.)
'23 Envelope #14 (5 x 11.5 in.)
'24 C size sheet (17 x 22 in.)
'25 D size sheet (22 x 34 in.)
'26 E size sheet (34 x 44 in.)
'27 Envelope DL (110 x 220 mm)
'28 Envelope C5 (162 x 229 mm)
'29 Envelope C3 (324 x 458 mm)
'30 Envelope C4 (229 x 324 mm)
'31 Envelope C6 (114 x 162 mm)
'32 Envelope C65 (114 x 229 mm)
'33 Envelope B4 (250 x 353 mm)
'34 Envelope B5 (176 x 250 mm
'35 Envelope B6 (176 x 125 mm)
'36 Envelope (110 x 230 mm)
'37 Envelope Monarch (3.875 x 7.5 in.)
'38 6-3/4 Envelope (3.625 x 6.5 in.)
'39 US Std Fanfold (14.875 x 11 in.)
'40 German Std Fanfold (8.5 x 12 in.)
'41 German Legal Fanfold (8.5 x 13 in.)
'256 User -defined

'Values for the PaperSize Member HJPDJ650
'Value Paper size
'54 A2 (420 x 594mm)
'55 A1 (594 x 841mm)
'56 A0 (841 x 1189mm)

--
Med venlig hilsen / Best regards / Mit freundlichen Grüßen

Poul Berthelsen
B.Sc. in engineering
Mechanical Designer

p...@pjm.dk
Poul Johansen Maskiner A/S
DK-4540 Fårevejle
http://www.pjm.dk

---MS warning dialog box: "You do not have permission to shut down and
restart this computer [OK]"---


guyjo...@gmail.com

unread,
May 3, 2016, 8:54:10 AM5/3/16
to
Hello, I try to adapt this code. How can I find 'Values for the PaperSize' for my plotter ?
0 new messages