{"id":16730,"date":"2017-05-12T11:00:05","date_gmt":"2017-05-12T15:00:05","guid":{"rendered":"https:\/\/blogs.solidworks.com\/tech\/?p=16730"},"modified":"2017-05-09T09:15:17","modified_gmt":"2017-05-09T13:15:17","slug":"solidworks-pdm-forms-series-part-2-word-documents-as-forms","status":"publish","type":"post","link":"https:\/\/blogs.solidworks.com\/tech\/2017\/05\/solidworks-pdm-forms-series-part-2-word-documents-as-forms.html","title":{"rendered":"SOLIDWORKS PDM Forms Series Part 2: Word Documents as Forms"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4001\" src=\"https:\/\/blog.dasisolutions.com\/wp-content\/uploads\/2016\/09\/pdm-tips-header.jpg\" alt=\"SOLIDWORKS PDM Tech Tip\" width=\"600\" height=\"317\" \/><\/p>\n<p><em>Written by: Bryce Hooper, Application Engineer, DASI Solutions<\/em><\/p>\n<p>Continuing our series on automating forms inside of SOLIDWORKS PDM, we\u2019ll move along with an example in Microsoft Word. <em>(See Part 1 on Excel docs as forms <a href=\"https:\/\/blog.dasisolutions.com\/2017\/02\/21\/solidworks-pdm-forms-series-part-1-excel-documents-as-forms\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.)<\/em><\/p>\n<p>Here is our example of an Engineering Change Notice form:<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4236\" src=\"https:\/\/blog.dasisolutions.com\/wp-content\/uploads\/2017\/03\/WordForm1.png\" alt=\"Engineering Change Notice\" width=\"550\" height=\"530\" \/><\/p>\n<p>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 <a href=\"https:\/\/blog.dasisolutions.com\/2017\/02\/21\/solidworks-pdm-forms-series-part-1-excel-documents-as-forms\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel forms<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4237\" src=\"https:\/\/blog.dasisolutions.com\/wp-content\/uploads\/2017\/03\/WordForm2.png\" alt=\"Edit Variable\" width=\"391\" height=\"586\" \/><\/p>\n<p>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.<\/p>\n<p>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.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4238\" src=\"https:\/\/blog.dasisolutions.com\/wp-content\/uploads\/2017\/03\/WordForm3.png\" alt=\"Microsoft Word Advanced Properties\" width=\"336\" height=\"205\" \/><\/p>\n<p>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\u2019t 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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4239\" src=\"https:\/\/blog.dasisolutions.com\/wp-content\/uploads\/2017\/03\/WordForm4.png\" alt=\"Document Properties\" width=\"386\" height=\"471\" \/><\/p>\n<p>Now that we\u2019ve 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 &gt; Quick Parts &gt; Field.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4240\" src=\"https:\/\/blog.dasisolutions.com\/wp-content\/uploads\/2017\/03\/WordForm5.png\" alt=\"Insert Field - Microsoft Word\" width=\"359\" height=\"240\" \/><\/p>\n<p>Do this with your cursor in the desired location, and the following dialog will help us add the right field.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-4241\" src=\"https:\/\/blog.dasisolutions.com\/wp-content\/uploads\/2017\/03\/WordForm6.png\" alt=\"SOLIDWORKS PDM Forms Series Part 2: Word Documents as Forms - Field Properties\" \/><\/p>\n<p>To get to our custom properties, we need to scroll down to the Field Name \u201cDocProperty\u201d. 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 \u201cOK\u201d. If we had filled in a value for the custom property, it will now show.<\/p>\n<p>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.<\/p>\n<ol>\n<li>Force an update each time we open by pressing Ctrl+A and then F9<\/li>\n<li>Add a macro to update the fields on each open<\/li>\n<\/ol>\n<p>Here, I\u2019ll give you the code to do number two on that list.<\/p>\n<p>To start we\u2019ll need to create a new macro in Word. To do this, we can press Alt+F8. We get the dialog shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4242\" src=\"https:\/\/blog.dasisolutions.com\/wp-content\/uploads\/2017\/03\/WordForm7.png\" alt=\"Create new macro in Microsoft Word\" width=\"449\" height=\"371\" \/><\/p>\n<p>Click \u201cCreate\u201d and paste in the following code snippet:<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"623\"><span style=\"color: #ff0000;\">Sub AutoOpen()<\/span><\/p>\n<p><span style=\"color: #ff0000;\">\u00a0\u00a0\u00a0 With Options<\/span><\/p>\n<p><span style=\"color: #ff0000;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .UpdateFieldsAtPrint = True<\/span><\/p>\n<p><span style=\"color: #ff0000;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 .UpdateLinksAtPrint = True<\/span><\/p>\n<p><span style=\"color: #ff0000;\">\u00a0\u00a0\u00a0 End With<\/span><\/p>\n<p><span style=\"color: #ff0000;\">\u00a0\u00a0\u00a0 ActiveDocument.Fields.Update<\/span><\/p>\n<p><span style=\"color: #ff0000;\">End Sub<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Save and close the VB editor. From now on, each time the file is opened the fields should update.<\/p>\n<p>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.<\/p>\n<p>There are, of course, some pros and cons to this technique. I\u2019ll break them down a bit here. By no means is this an all-encompassing list.<\/p>\n<p><strong>Pros:<\/strong><\/p>\n<ul>\n<li>Your company\u2019s forms are probably already in Word (or some other Office format), so the translation isn\u2019t difficult.<\/li>\n<li>If they aren\u2019t already in Word, this is an easy program for anyone else to learn and create forms.<\/li>\n<li>Setup for this is fairly simple and intuitive. The process works similarly for other office formats.<\/li>\n<\/ul>\n<p><strong>Cons:<\/strong><\/p>\n<ul>\n<li>The PDM Preview window does not update until the file has been checked out, opened, saved, and checked back in.<\/li>\n<li>Requires Microsoft Office on any machine that would need to view\/print it.<\/li>\n<li>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.<\/li>\n<li>As of this article, some variable types either don\u2019t work (Yes\/No) or don\u2019t display correctly (Date)<\/li>\n<li>Requires a macro to update correctly.<\/li>\n<\/ul>\n<p>If you\u2019re looking for other ways to create forms inside of PDM, you may also want to check out <a href=\"https:\/\/blog.dasisolutions.com\/2017\/02\/21\/solidworks-pdm-forms-series-part-1-excel-documents-as-forms\/\" target=\"_blank\" rel=\"noopener noreferrer\">our blog on Microsoft Excel forms<\/a> and watch for our upcoming third part in the series covering XML documents as forms in PDM.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Written by: Bryce Hooper, Application Engineer, DASI Solutions Continuing our series on automating forms inside of SOLIDWORKS PDM, we\u2019ll move along with an example in Microsoft Word. (See Part 1 on Excel docs as forms here.) Here is our example<\/p>\n... <a href=\"https:\/\/blogs.solidworks.com\/tech\/2017\/05\/solidworks-pdm-forms-series-part-2-word-documents-as-forms.html\">Continued<\/a>","protected":false},"author":144,"featured_media":16778,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25,35],"tags":[487,603,1874,1006,144,453],"class_list":["post-16730","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-solidworks-enterprise-pdm","category-tips-tricks","tag-automation","tag-data-management","tag-pdm-forms","tag-solidworks-pdm","tag-tech-tips","tag-tips-and-tricks"],"acf":[],"_links":{"self":[{"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/posts\/16730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/users\/144"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/comments?post=16730"}],"version-history":[{"count":4,"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/posts\/16730\/revisions"}],"predecessor-version":[{"id":16779,"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/posts\/16730\/revisions\/16779"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/media\/16778"}],"wp:attachment":[{"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/media?parent=16730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/categories?post=16730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.solidworks.com\/tech\/wp-json\/wp\/v2\/tags?post=16730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}