need a simple SW2009 print macro
need a simple SW2009 print macro
(OP)
I am looking for a *.swp file that I can add to my SolidWorks 2009 toolbar that allows me to print the current drawing file on the screen to a specific printer and at a specific size.
My issue is that I have 5 printers on the premises. I am tired of fumbling through the print options. I would like to hit a print button and go pick the print up. I would like to set up a toolbar button to say print a B-size to HP 5200 BW printer. Then another toolbar button to print A-size to HP 9500 color printer. ETC.
Does anyone have the VBA skills to provide such an invaluable macro?
My issue is that I have 5 printers on the premises. I am tired of fumbling through the print options. I would like to hit a print button and go pick the print up. I would like to set up a toolbar button to say print a B-size to HP 5200 BW printer. Then another toolbar button to print A-size to HP 9500 color printer. ETC.
Does anyone have the VBA skills to provide such an invaluable macro?






RE: need a simple SW2009 print macro
-handleman, CSWP (The new, easy test)
RE: need a simple SW2009 print macro
Note the Paper Size and printer names depends of printer settings.
If you aren't sure what are the correct values. I'm proposing to do the following:
Set the first printer as default and choose required papper size on "Page Setup" Dialog. Uncomment
'Debug.Print swPageSetup.PrinterPaperSize
'Debug.Print swModel.Printer lines and copy-paste the values from output window.
Reply these actions for every printer and paper size you would like the macro being created.
Do you know how to add the macro to custom button? If no - please let me know I explain how to do this.
- - - - - - - - - - -
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPageSetup As SldWorks.PageSetup
Const Printer As String = "Microsoft XPS Document Writer"
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPageSetup = swModel.PageSetup
'Debug.Print swPageSetup.PrinterPaperSize
'Debug.Print swModel.Printer
'A4 = 9, A3 = 8
swPageSetup.PrinterPaperSize = 8
swPageSetup.Orientation = 2 ' 1=Portrait '2 = Landscape
swModel.Extension.PrintOut2 Empty, 1, False, Printer, ""
End Sub
- - - - - - - - - - -
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com
RE: need a simple SW2009 print macro
one more thing. Is there a way to 'scale to fit'? For instance, if I want to print an A3 drawing on my screen to an A4 piece of paper, is there a simple code to add to the code you already gave me?
RE: need a simple SW2009 print macro
Add the following line to your code:
...
swPageSetup.ScaleToFit = True
...
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com
RE: need a simple SW2009 print macro
Suede, may be you can simply club them into a single macro with a user form having button to click on. Check the attached picture.
Deepak Gupta
SW2009 SP3.0
SW2007 SP5.0
MathCAD 14.0
RE: need a simple SW2009 print macro
BTW. The option buttons can also be used. Or for example a combination of option buttons for printer types and paper sizes. And the checkbox for "Scale to Fit" option.
But this can return us to initial SW dialogs which SUEDE would like to avoid.
SUEDE, you can also create a separate toolbar for your buttons. Some time ago I've attached a simple addin for doing this. by some reason not all users have been able to make it work
refer http://www.eng-tips.com/viewthread.cfm?qid=246216
Artem Taturevich, CSWP
Software and Design Engineer
AMCBridge LLC
www.amcbridge.com
RE: need a simple SW2009 print macro
In the future, I may begin to play with the "single macro" or "separate toolbar" ideas as well
Thanks for making my week!
RE: need a simple SW2009 print macro
Joe
SW Office 2008 SP5.0
P4 3.0Ghz 3GB
ATI FireGL X1
RE: need a simple SW2009 print macro
The debug commands output to the Immediate window in the VBA IDE/Editor. Click the icon of a window with an exclamation point to hide/show the Immediate window.
RE: need a simple SW2009 print macro
Joe
SW Office 2008 SP5.0
P4 3.0Ghz 3GB
ATI FireGL X1