Built for SOLIDWORKS® & SOLIDWORKS PDM Professional ·

Publisher Macros: Automate PDMPublisher from SOLIDWORKS VBA

Most SOLIDWORKS automation starts as a VBA macro, and most of the time the hard part is not the macro but everything around it: choosing the right filename, checking the copy in to SOLIDWORKS PDM Professional, fixing custom properties on a dozen files, or pushing a bill of materials to ERP. Publisher Macros in PDMPublisher for SOLIDWORKS exposes the add-in’s utility commands, Save As New, Property Doctor, Clone Tree and ERP Sync, as late-bound methods you can call from any VBA macro, and gives you an editor and runner inside SOLIDWORKS so you do not need the SOLIDWORKS macro editor just to try one out.

Publisher Macros VBA editor in PDMPublisher for SOLIDWORKS showing a Sub main() example with syntax highlighting, line numbers and the Run, OK and Cancel buttons
The Publisher Macros editor ships with a complete Sub main() example. Edit the profile names, uncomment the commands you want, and select Run.

What Publisher Macros does

Publisher Macros is listed in the Integration group of the PDMPublisher CommandManager tab. Selecting it opens an editable VBA example with syntax highlighting and line numbers, a Run button that executes the displayed code through SOLIDWORKS, and OK and Cancel buttons that decide whether your edits are retained for the next session.

The example code connects to the loaded PDMPublisher add-in with GetAddInObject and then calls PDMPublisher commands by name. Because the connection uses late binding, the macro does not need a PDMPublisher VBA reference, and the same code works from a normal .swp macro, from a SOLIDWORKS macro button, or from the Publisher Macros editor itself.

The commands you can call are the four utility commands of the add-in. Each one takes a saved profile (or, for ERP Sync, a connector name plus explicit arguments) and a silent flag that decides whether the normal PDMPublisher window is shown or whether the command runs to completion without dialogs.

  • Save As New: save the active document as a separate native SOLIDWORKS file using a saved naming and destination profile.
  • Property Doctor: apply a saved property-action profile to the active document and its references.
  • Clone Tree: copy a document set with per-file names and destinations using a saved Clone Tree profile.
  • ERP Sync: push SOLIDWORKS or CSV data to an ERP connector, or pull mapped ERP properties back, with the review window open.

Publisher Macros is different from Run macro after saving on the Save As New settings page. That option runs a macro method on the newly saved copy before automatic PDM check-in. Publisher Macros is the reverse: your macro is the caller, and PDMPublisher commands are what it runs.

Why it matters for an engineering office

The add-in commands are already one-click operations, but a macro lets you chain them and drive them from your own logic. A release macro can save a customer variant with the BC Save As New profile, run the Default Property Doctor profile to normalize Description, Material and Revision, and then open ERP Sync with the assembly BOM already selected for the ERPNext connector. None of that requires the user to remember which profile to pick from the arrow menu.

It also gives you a stable surface for larger SOLIDWORKS automation. If you already have a macro library that opens models, sets configurations or renames files, adding a PDMPublisher call is a few lines. Profile names are case-insensitive, and calls made without arguments simply open the command interactively, exactly as the CommandManager button would.

How it works

  1. Load PDMPublisher (SOLIDWORKS) under Tools > Add-Ins. The add-in must be loaded before any macro can obtain the publisher object.
  2. Save the profiles and connector settings the macro will use. Save As New, Property Doctor and Clone Tree profiles are created from their pages in PDMPublisher > Settings; ERP Sync connectors are configured on the ERP Sync settings page.
  3. Open PDMPublisher > Publisher Macros from the CommandManager, from Tools > PDMPublisher > Publisher Macros, or from PDMPublisher > Settings > Publisher Macros.
  4. Replace the example profile or connector names with names that exist on this computer. On first use the example selects available Save As New and Property Doctor profiles when possible.
  5. Uncomment only the commands you intend to execute.
  6. Select Run to execute the displayed code through SOLIDWORKS. Run requires a Sub main() entry point.
  7. Review any PDMPublisher window, result or error opened by the macro.
  8. Select OK to retain the edited code for the next session, or Cancel to discard the edits. Later sessions restore the code most recently retained with OK.

Cancel does not undo operations that were already executed by Run. If the macro saved a file or applied properties, those changes stand.

PDMPublisher tab in the SOLIDWORKS 2026 CommandManager showing Save As New, Property Doctor, Clone Tree, ERP Sync, Publisher Macros, BOM Manager, Publish, Annotations, Conditions, Logs, Settings and License Key
Publisher Macros sits in the Integration group of the PDMPublisher CommandManager tab, next to ERP Sync.

Connect to PDMPublisher from VBA

Every macro starts by asking SOLIDWORKS for the add-in object. The GUID below identifies the PDMPublisher add-in; it is the same on every installation. Use late binding (As Object) so no reference needs to be added in the VBA editor.

The complete example as shown in the documentation:

  • Dim publisher As Object
  • Set publisher = Application.SldWorks.GetAddInObject( _
  • "{9BC55484-9BC0-431E-B039-E9CC13542E43}")
  • If publisher Is Nothing Then
  • Err.Raise vbObjectError + 1, , _
  • "Load PDMPublisher in Tools > Add-ins first."
  • End If

If GetAddInObject returns Nothing, the add-in is not loaded in this SOLIDWORKS session. Enable it under Tools > Add-Ins and run the macro again.

Command reference: every object, method and argument

The publisher object exposes four automation methods. Profile names are case-insensitive. A blank, missing or ambiguous profile name fails. Calls without arguments retain the interactive behavior of the CommandManager button. The older SaveAsNewWithProfile, CloneTreeWithProfile and PropertyDoctorWithProfile methods remain supported for existing macros.

MemberSignatureWhat it does
publisher objectApplication.SldWorks.GetAddInObject("{9BC55484-9BC0-431E-B039-E9CC13542E43}")The PDMPublisher add-in object. Returns Nothing when the add-in is not loaded.
SaveAsNewpublisher.SaveAsNew profileName, silentRuns Save As New on the active document with the named Save As New profile. Interactive mode shows the destination dialog.
PropertyDoctorpublisher.PropertyDoctor profileName, silentRuns Property Doctor with the named action profile. Changes documents as the normal Apply does; save the documents afterward.
CloneTreepublisher.CloneTree profileName, silentRuns Clone Tree on the active document set with the named Clone Tree profile.
ERPSyncpublisher.ERPSync connectorName, direction, sourceType, sourcePath, bomTableName, itemTypes, operations, silentOpens ERP Sync for the named connector with the source, item types and operations preselected. Push and Pull require the review window, so use silent = False.
SaveAsNewWithProfilelegacyOlder equivalent of SaveAsNew; still supported.
PropertyDoctorWithProfilelegacyOlder equivalent of PropertyDoctor; still supported.
CloneTreeWithProfilelegacyOlder equivalent of CloneTree; still supported.

The silent argument: interactive versus unattended

Every method accepts a silent Boolean as its last argument. It controls whether PDMPublisher shows its usual progress, review and result dialogs.

  • Community Edition limits continue to apply when a command is run from a macro (5 references, 5 Clone Tree rows, 5 Property Doctor rows, 10 ERP Sync rows per run).
  • Completed changes are not rolled back if a later step in your macro fails.
  • Property Doctor changes documents exactly as its normal Apply operation does; save those documents afterward from your macro or manually.
  • Silent Save As New requires Premium, does not overwrite existing files, and rejects prompt placeholders, after-save macros and automatic PDM check-in. Its saved profile must contain enough destination information to run without a prompt.
  • ERP Push and Pull cannot run silently because PDMPublisher requires the user to review the diff before any remote or SOLIDWORKS change. silent = True on ERPSync stops before connecting and returns an error.
silent valueBehaviorNotes
FalseOpens the normal PDMPublisher interface with the requested profile or options. Save As New displays its destination dialog, and ERP Sync lets you review and uncheck rows before Push.Default behavior; identical to selecting the command from the CommandManager with that profile.
TrueRuns without PDMPublisher progress, review or result dialogs and waits for completion. Errors are returned to the VBA error handler.Silent Save As New requires Premium. ERP Sync cannot run silently.

ERPSync parameters

ERPSync is the only method with more than two arguments, because it has to describe where the data comes from, what it contains and what to do with it. All string values are case-insensitive.

ParameterSupported valueNotes
connectorNameA unique installed connector name with saved connection settings.Silent execution uses the named connector without changing the global connector selection.
directionPush or Pull.Pull requires a connector with preview support and must run interactively (silent = False).
sourceTypeFeatureTree, AssemblyBOM, DrawingBOM or CSV.Values are case-insensitive.
sourcePathA native document path, or blank to use the active document.CSV always requires a file path and does not require an open SOLIDWORKS document.
bomTableNameA BOM feature name, full displayed table/configuration label, or stable table ID.Can be blank only when exactly one table/configuration is available.
itemTypesAll, or a comma-separated list of Drawings, Parts, Assemblies, WeldmentCutListItems, SheetMetalCutListItems and PhantomItems.CSV requires All.
operationsA comma-separated list of Properties, CreateItems and BOM.CreateItems also synchronizes properties; BOM requires a source with valid hierarchy.
silentUse False.Current ERP Push and Pull require review; True stops before connecting and returns an error.

Example 1: basic commands with saved profiles

This is the example shipped in the editor. False opens each command with the named profile so you can review before committing. The Clone Tree line stays commented until a matching Clone Tree profile exists on the computer.

  • ' False opens the command with the named profile.
  • Call publisher.SaveAsNew("BC", False)
  • Call publisher.PropertyDoctor("Default", False)
  • ' Uncomment after saving a matching Clone Tree profile.
  • ' Call publisher.CloneTree("My clone profile", False)

Example 2: open ERP Sync with the feature tree preselected

This call opens the ERP Sync review window for the ERPNext connector, sourcing parts and assemblies from the active document’s feature tree, and preparing a Push that synchronizes properties, creates missing items and uploads the BOM. The two blank strings leave sourcePath (active document) and bomTableName (not needed for a feature tree source) empty.

  • Call publisher.ERPSync( _
  • "ERPNext", _
  • "Push", _
  • "FeatureTree", _
  • "", _
  • "", _
  • "Parts,Assemblies", _
  • "Properties,CreateItems,BOM", _
  • False)

For native documents, files opened by automation remain available in SOLIDWORKS. ERP-generated part numbers can leave documents modified and requiring a save. See the ERP Sync article for connector behavior.

Example 3: handle errors safely

Authentication, profile validation, license limits, document state and external integrations can all stop an operation. Wrap the calls in a VBA error handler so a failure surfaces as a message instead of an unhandled runtime error in SOLIDWORKS.

  • Sub main()
  • On Error GoTo Failed
  • ' Obtain the publisher object and run one or more commands here.
  • Exit Sub
  • Failed:
  • MsgBox Err.Description, vbExclamation, "PDMPublisher"
  • End Sub

Set it up in the SOLIDWORKS add-in

  1. In SOLIDWORKS, open Tools > Add-Ins and load PDMPublisher (SOLIDWORKS). Tick the start-up box if you want it loaded every session.
  2. Open PDMPublisher > Settings. On the Save As New, Property Doctor and Clone Tree pages, create and save the profiles you will call by name. On the ERP Sync page, configure the connector and save its connection settings.
  3. Select OK to save the settings.
  4. Open PDMPublisher > Publisher Macros (CommandManager, Tools > PDMPublisher menu, or Settings > Publisher Macros).
  5. Edit the profile names in the example, uncomment the commands you want, and select Run.
  6. Check the PDMPublisher windows or results the macro opened. Select OK to keep the code for next time.
Publisher Macros page in the PDMPublisher for SOLIDWORKS Settings dialog with the button that opens the editable VBA example
The Publisher Macros settings page opens the same editor. Retained VBA code is stored locally for the current Windows user and is not part of the settings bundle.

Use the calls from your own SOLIDWORKS macro

The Publisher Macros editor is convenient for testing, but the calls are ordinary COM calls. Paste the connection snippet and any command into a .swp macro created with Tools > Macro > New, assign it to a macro button on your own toolbar, or call it from a larger automation routine that opens models, changes configurations and saves. Nothing changes: the add-in must be loaded, the profiles must exist on that computer, and the silent rules above still apply.

  • Test on non-production documents first.
  • Third-party and PDM integrations can require their own login or permissions; a macro cannot bypass the SOLIDWORKS PDM Professional permissions of the user running it.
  • The retained code in the Publisher Macros editor is per Windows user and per computer. Keep your production macro in a shared macro folder rather than relying on the editor’s retained copy.

Recipes

Three short scenarios built only from the calls above.

  1. Customer variant in one click. Create a Save As New profile named BC with a filename template and destination for customer copies. Macro: Call publisher.SaveAsNew("BC", False). The destination dialog opens so the user confirms, then the copy is saved and, if the profile enables it, checked in to PDM.
  2. Property cleanup before release. Save a Property Doctor profile named Default that fills Description and Revision. Macro: Call publisher.PropertyDoctor("Default", True) on Premium runs it without dialogs; follow with your own save loop because Property Doctor leaves the documents modified.
  3. BOM handoff to ERP. After the assembly is saved, call ERPSync with "AssemblyBOM" as sourceType, the BOM table name as bomTableName, "All" for item types and "Properties,CreateItems,BOM" for operations, silent = False. The review window opens with everything preselected; the user unchecks rows and selects Push.

Tips, limits and troubleshooting

  • The publisher object is Nothing. PDMPublisher is not loaded. Enable it under Tools > Add-Ins; the example raises a descriptive error for this case.
  • Run does nothing or reports a missing entry point. Run requires a Sub main(). Keep the entry point name exactly as in the example.
  • A profile name fails. The name must exist on this computer and be unique. Blank, missing or ambiguous names fail. Names are case-insensitive, so bc and BC are the same profile.
  • Silent Save As New fails. It requires Premium, refuses to overwrite existing files, and rejects profiles with prompt placeholders, after-save macros or automatic PDM check-in. Use False or adjust the profile.
  • ERPSync with silent = True returns an error. This is by design: Push and Pull require the review window. Use False.
  • Community Edition row and reference limits apply per operation exactly as they do from the CommandManager.
  • Nothing is rolled back. If step three of your macro fails, steps one and two stay applied. Design macros so each step is safe on its own, and check PDMPublisher > Logs for the detailed processing log of any publish-related operation.
  • Documents stay modified. Property Doctor and ERP-generated part numbers leave files needing a save. Save them from the macro or in SOLIDWORKS.
  • Settings transfer. Retained VBA code is stored locally for the current Windows user and is not included in the complete settings bundle exported from Settings > Export. Profiles are included, so a colleague who imports your bundle gets the profiles your macro names, but not the macro text.

Availability

Available in PDMPublisher for SOLIDWORKS, the add-in that runs inside SOLIDWORKS. Not part of the PDM Professional task. Publisher Macros is a command of the PDMPublisher for SOLIDWORKS add-in. It automates the add-in’s utility commands from VBA inside SOLIDWORKS and has no equivalent in the PDM Professional task, which is driven by workflow transitions, right-click commands and scheduled items instead.

Documentation and related features

Frequently asked questions

Can I call PDMPublisher from a SOLIDWORKS VBA macro?

Yes. Get the add-in object with Application.SldWorks.GetAddInObject(“{9BC55484-9BC0-431E-B039-E9CC13542E43}”) and call SaveAsNew, PropertyDoctor, CloneTree or ERPSync on it. Late binding means no VBA reference is required; the add-in only has to be loaded under Tools > Add-Ins.

Do I need a PDMPublisher type library reference in the VBA editor?

No. Publisher Macros uses late binding (Dim publisher As Object), so the macro works without adding any reference.

Can Save As New run without any dialog?

Yes with silent = True, which requires Premium. The saved profile must contain enough destination information to run without a prompt, and it cannot use prompt placeholders, after-save macros or automatic PDM check-in. Existing files are never overwritten.

Why does ERPSync fail when I pass silent = True?

ERP Push and Pull always require the user to review the diff before any remote or SOLIDWORKS change, so silent execution stops before connecting and returns an error. Pass False and the review window opens with your arguments preselected.

Are my macro edits saved?

Select OK in the Publisher Macros editor to retain the code for the next session; Cancel discards the edits. The retained code is stored locally for the current Windows user and is not included in exported settings bundles.

Do the older SaveAsNewWithProfile methods still work?

Yes. SaveAsNewWithProfile, CloneTreeWithProfile and PropertyDoctorWithProfile remain supported alongside the current SaveAsNew, CloneTree and PropertyDoctor methods.

Where to next

PDMPublisher for SOLIDWORKS · PDMPublisher for PDM Professional · All features · Conversion guides · Pricing · Documentation · Contact

The SOLIDWORKS add-in is free to start as the Community Edition. The PDM Professional task comes with a 7-day trial. Download the add-in or start the task trial.