6 Replies Latest reply on Aug 11, 2015 9:03 AM by Chris Mackedanz

    Print Macro

    Hrituc Alexandru

           Hi everyone,

      I want to create a Print Macro who run to specific folder and Print to specific printer with posibility to print all drawings (.slddrw) or all pdf from the specified folder.

      If it's hard to made one such macro I appreciate if you help me to start...

                Thanks and have a nice day,

        • Re: Print Macro
          Deepak Gupta

          Task Scheduler > Print Files

            • Re: Print Macro
              Hrituc Alexandru

              i know but it not works with pdfs...

                • Re: Print Macro
                  Erick Bienvenue

                  I think you doesn't can do this in vba, you will have to do this in visual basic or vb.net to print the pdf native file because Solidworks doesn't open this type of file.

                    • Re: Print Macro
                      Chris Mackedanz

                      Hey can do it in VBA in SolidWorks, as long as he has a program that can open and print PDFs on his machine which he can add a reference to and can send commands to like a VBA macro does to SolidWorks.


                      Just go to tools > References and add "Adobe Acrobat 8.0 Type Library" (at least for me it was 8.0)


                      Check out this PDF from Adobe about it: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/iac_developer_guide.pdf


                      I've never actually written a macro to print a PDF, but it should be possible.

                        • Re: Print Macro
                          Hrituc Alexandru

                          Hi Chris,

                          The same version is found at me


                            • Re: Print Macro
                              Chris Mackedanz

                              That's a start.


                              I don't have time to really look into what you would have to do next, and your entire macro will be kind of large and tricky.


                              I'd use the File Scripting Object (FSO) to read and interact with files and folders.  Something like:



                              1. Create objects and assign objects and variables such as FSO, SLDDWRKS, Adobe, and strings to hold folders and filenames.  Maybe even get creative and add integer variables to count how many .slddrw and .pdf files there are in the folder, and each time one prints count increments by one, and have a progress bar on your form and update it... to give user feedback so they don't think your macro froze.
                              2. Create a nice user form to hold status bar, a button to launch to FSO to get a folder to print, a "GO" button, and maybe even a label or text box with the path & filename BEING printed...
                              3. Get folder to print from user.
                              4. For each item in folder
                                1. if Solidworks drawing file = true then
                                  1. open in solidworks and print
                                2. if .pdf = true then
                                  1. open with Adobe Acrobat object and print
                              5. Loop till all files have been printed / checked to see if they are printable.
                              6. Msgbox to notify user that all files printed/or we are done/ or something went horribly terribly wrong and they may need a new printer....(ok the last bit was a joke...I hope they don't need a new printer after your macro runs )


                              Sorry I can't post code examples...