US$0.00
0

SOLIDWORKS Macro to Save Drawings as PDF (Toolbar Button Integration)

Description

This macro is a one-action solution that exports the active SolidWorks drawing as a PDF file. It combines all the drawing sheets into one single PDF file. This utility is made to be paired with a custom button on the SolidWorks toolbar as a quick one-click way for engineers to create a SolidWorks PDF directly from the drawing environment. The SOLIDWORKS macro to save drawings as PDF makes this process even more efficient by automating the export with a single command.

System Requirements

  • SolidWorks Version: SolidWorks 2014 or newer
  • Operating System: Windows 7 or later

Pre-Conditions

  • The active document must be a saved drawing file (.SLDDRW). 
  • The drawing file must have a valid path (not saved to read-only). 
  • This macro is designed to exclusively work with drawing documents and will not work with part or assembly files.

Results

  • Every sheet contained in the active drawing is exported into a single PDF file. 
  • The PDF file is automatically saved in the same directory as the original drawing file, and uses the original drawing name with the extension of .PDF. 
  • A message box indicates the status of the operation (Completion status or Failure).

Steps to Set Up the Macro

To create the one-click PDF export functionality:

  1. Create the Macro File: In SolidWorks, choose Tools > Macro > New….
  2. Save the File: Give the macro a name (e.g.,  ExportDrawingPDF.swp) and save it to a location you intend to keep it. The VBA editor will launch immediately after.
  3. Insert the Code: Copy the code from the “VBA Macro Code” below and paste it in the VBA editor, erasing the prefilled content.
  4. Save and Close: Save in the VBA editor.
  5. Create the Button on the Toolbar:
    • Go to: Tools > Customize (this can also be called Options > Customize).
    • Click on the Commands tab.
    • Select Macro from the Categories list.
    • Click and drag the ‘New Macro Button’ and drop it in an existing toolbar, or create a new custom toolbar.
    • Configure the Button: Right-click the new button and select “Customize Macro Button…”.
      • Macro File: Browse to the folder where you saved the ExportDrawingPDF.swp and select it.
      • Method: Specify the main subroutine.
      • Tooltip/Image: Provide an appropriate tooltip (e.g., One-Click Save as PDF) and also provide a toolbar icon.

VBA Macro Code

Macro

You can download the macro from here

Need a Macro Developed to Improve Your Custom Workflow?

Contact us to either customize this macro or build completely new solutions to satisfy your specific workflow needs precisely.

Author

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM. With over a decade of experience, he has authored several courses and open-source frameworks related to the SOLIDWORKS API. His leadership ensures that Blue Byte Systems prioritizes customer satisfaction and delivers high-quality software and CAD design solutions.
0
    0
    Your Cart
    Your cart is emptyReturn to Shop
    ×