SOLIDWORKS, PDM

SOLIDWORKS PDM (Part 2): Inserting Form Fields and Linking Microsoft Office Files

By Chris Kolling on July 6, 2018

To conclude our two-part blog series, we will describe how to refresh and enable linking to SOLIDWORKS PDM. Plus, we'll outline how to have the variables dynamically link to the PDM metadata.

Watch our On-Demand Webinar below, or follow these steps.

 

Designing and Inserting Form Fields in Microsoft Word

  1. With your Word document open, we want to insert form fields to link to our custom properties.
  2. Put the cursor where you want the field to be placed, and from the Insert ribbon tab, select Quick Parts, then Field. Insert a Field under Quick Parts
  3. Select “DocProperty” under the Field Names column, followed by the custom property that you would like to link to the form field. Click OK to place the field for the property where your cursor is currently located.Select DocProperty under File Names column

This will insert a field linked to the value of the property. You can toggle the display of the field by pressing ALT – F9. This will display something similar to {DOCPROPERTY nameofproperty \* MERGEFORMAT}.

Adding a Refresh Macro in Word

Microsoft Word security protocol dictates that linked properties are not automatically updated when a document is opened. To update, all fields must be selected (Control-A) and then press F9 to refresh the text. A better method to update the form fields in Word automatically is to use a refresh macro. To add a refresh macro in Word, follow these steps:
  1. Start Microsoft Word.
  2. Open the Word options by clicking on File > Options (at the bottom left).
  3. Select “Customize Ribbon” on the left. Under Customize the Ribbon, check the box next to Developer.Customize Ribbon Word Options
  4. From the Developer tab: 
    1. Select Macro Settings.
    2. Select Enable all macros, hit OK. Enable all macros
    3. From the macros dialog, create a macro called AutoOpen and click Create.
    4. In the code window, insert the following macro code in the new AutoOpen, then save and close the code window. 
      1. Sub AutoOpen()
      2. Dim aStory As Range
      3. Dim aField As Field
      4. For Each aStory In ActiveDocument StoryRanges
      5. For Each aField In aStory.Fields
      6. aField.Update
      7. Next aField
      8. Next aStory
      9. End sub

NewMacros (Code)

Now that this macro is defined, the next time the document is opened with fields that are linked to SOLIDWORKS PDM variables, the fields will be automatically updated.

>> Watch our On-Demand Webinar, Automate Folder and File Creation with Templates in SOLIDWORKS PDM Professional 

Defining Content Driven by Microsoft Excel Document Properties

Microsoft Excel is a much easier way to enable fields to be linked to SOLIDWORKS PDM variables than Word. To link Excel cells to PDM variables that you have created:
  1. Linking SOLIDWORKS PDM Variables in Microsoft ExcelOpen up your Excel document, and highlight the cell where you would like a PDM variable to link to.
  2. Under the ribbon in Excel, you will see a box with the cell ID (such as B5) in the upper left. Type the name of the PDM variable that you have linked for CustomProperty for Excel files.
  3. Now we need to link the named cell to the custom property. Click File, then the drop-down next to Properties and choose Advanced Properties. Select the Custom tab.Select Advanced Properties under File
  4. Link to Content BoxSelect a custom property, check the “Link to Content” box and then choose the named cell next to Source. In our example, the custom property is ECO Number (which is mapped in PDM to an Excel custom property), and we want to link that to the named cell ECNum from step 2 above.
  5. The values of the properties and cells are updated automatically when the worksheet is recalculated. No macro is necessary.

Once these steps are complete, you're ready to go!

For personal instruction, try our SOLIDWORKS PDM training classes. The hands-on, interactive instruction makes for a great learning experience. Find one near you now!

PDM Training Classes