Written by: Bryce Hooper, Application Engineer
Continuing our series on automating forms inside of PDM, we’ll move along with an example in Microsoft Word. (See Part 1 on Excel docs as forms here.)
Here is our example of an Engineering Change Notice form.
Now, to map these properties to our file and our data card, we will need to start with the variable setup. For Microsoft Office documents, the setup is pretty simple. For each variable we are mapping we will want to use the attribute block CustomProperty. This should be familiar as it is the same that we would use for SOLIDWORKS documents and was also noted in our article about Excel forms.
Set this to use the proper extensions that we are intending to use and the rest of the options can be set at your discretion.
It is then time to map the custom properties to those ranges. This is done by going to the file info inside of Word, then properties and Advanced properties.
In the dialog that shows we go to the Custom tab. Here we find a list of properties that are already defined. Any variables that have already been assigned a value inside of PDM will automatically be created. Any that haven’t we will create now. To do this, we give the property a name in the Name field and then give it a value in the Value field. A space will work for this value, but in the interest of seeing what we are setting up, it may be advantageous to give this a realistic value to get our formatting right.
Now that we’ve created the custom properties inside of Word, we can enter them into the body of our document. This is done by going to the Insert tab > Quick Parts > Field.
Do this with your cursor in the desired location, and the following dialog will help us add the right field.
To get to our custom properties, we need to scroll down to the Field Name “DocProperty”. This will give us the Field Property of our available custom properties (plus some file properties). Select the custom property that we need to enter and click “OK”. If we had filled in a value for the custom property, it will now show.
For Word, custom properties and the fields they are linked to do will not update automatically or open by themselves. We have two options in this case.
- Force an update each time we open by pressing Ctrl+A and then F9
- Add a macro to update the fields on each open
Here, I’ll give you the code to do number two on that list.
To start we’ll need to create a new macro in Word. To do this, we can press Alt+F8. We get the dialog shown below.
Click “Create” and paste in the following code snippet:
.UpdateFieldsAtPrint = True
.UpdateLinksAtPrint = True
Save and close the VB editor. From now on, each time the file is opened the fields should update.
From here, we can make things even easier by creating a template to help us fill in values or serialize a naming convention. We can also create actions in our workflow transitions to automatically fill in names and dates for approvals.
There are, of course, some pros and cons to this technique. I’ll break them down a bit here. By no means is this an all-encompassing list.
- Your company’s forms are probably already in Word (or some other Office format), so the translation isn’t difficult.
- If they aren’t already in Word, this is an easy program for anyone else to learn and create forms.
- Setup for this is fairly simple and intuitive. The process works similarly for other office formats.
- The PDM Preview window does not update until the file has been checked out, opened, saved, and checked back in.
- Requires Microsoft Office on any machine that would need to view/print it.
- Does not handle changes down the line to the form/format with ease. I.E.: As your company uses the process and changes the formatting or logo, old forms will not update to the new format without manual updates.
- As of this article, some variable types either don’t work (Yes/No) or don’t display correctly (Date)
- Requires a macro to update correctly.
If you’re looking for other ways to create forms inside of PDM, you may also want to check out our blog on Microsoft Excel forms and watch for our upcoming third part in the series covering XML documents as forms in PDM.