{"id":899,"date":"2011-12-25T00:30:13","date_gmt":"2011-12-25T05:30:13","guid":{"rendered":"http:\/\/swildow.darktech.org\/wp\/?p=899"},"modified":"2011-12-25T00:30:13","modified_gmt":"2011-12-25T05:30:13","slug":"word-use-styleref-field-to-populate-headerfooter","status":"publish","type":"post","link":"https:\/\/www.wildow.com\/blog\/?p=899","title":{"rendered":"Word: Use StyleRef field to populate header\/footer"},"content":{"rendered":"<p>Many corporate documents require you to have a table near the beginning of the document with details such as the author, the date created, a revision number etc. You may also be required to insert some of these details into the header and\/or footer of the Word document.<\/p>\n<p><a href=\"http:\/\/cybertext.wordpress.com\/2009\/01\/30\/word-use-styleref-field-to-populate-headerfooter\/\">http:\/\/cybertext.wordpress.com\/2009\/01\/30\/word-use-styleref-field-to-populate-headerfooter\/<\/a><\/p>\n<p><!--more--><\/p>\n<p>While you can set up all sorts of macros, cross-references, document property fields etc. to do this, here\u2019s a really quick solution using styles and the StyleRef field. This solution works in both Word 2003 and Word 2007. Before attempting this, you should know how to create a new style in your version of Word.<\/p>\n<ol>\n<li>Create new styles for the text elements you want to capture. Give these styles names that are unique and are unlikely to be used anywhere else in the document (this is critical).\u00a0 For example,\u00a0<strong>DocAuthor<\/strong>,\u00a0<strong>DocDate<\/strong>,<strong>DocTitle<\/strong>,\u00a0<strong>DocRevNum<\/strong>. Don\u2019t worry about formatting \u2014 the header\/footer styles will control that.\n<div id=\"attachment_1347\"><img decoding=\"async\" title=\"Create new styles\" src=\"http:\/\/cybertext.files.wordpress.com\/2009\/01\/styleref00.png?w=490\" alt=\"Create new styles\" \/>Create new styles<\/p>\n<\/div>\n<\/li>\n<li>Fill in the details in the document information table (create a table if it doesn\u2019t already exist).<\/li>\n<li>Apply the relevant styles to each cell of the document information table \u2014 e.g. apply the DocTitle style to the cell containing the title.\u00a0 DO NOT apply these styles anywhere else in the document \u2014 only one paragraph\/cell in the entire document should have this style applied to it otherwise this solution won\u2019t work.\n<div id=\"attachment_1342\"><img decoding=\"async\" title=\"Apply the new styles\" src=\"http:\/\/cybertext.files.wordpress.com\/2009\/01\/styleref01.png?w=490\" alt=\"Apply the new styles to the relevant cells\" \/>Apply the new styles to the relevant cells<\/p>\n<\/div>\n<\/li>\n<li>Open the header or footer (<em>Word 2003<\/em>:\u00a0<strong>View &gt; Header and Footer<\/strong>;<em>Word 2007<\/em>:\u00a0<strong>Insert &gt; Header &gt; Blank<\/strong>\u00a0then remove the control).<\/li>\n<li>Insert a StyleRef field for each of the elements you want to populate.\u00a0 To insert a field:\u00a0<em>Word 2003<\/em>:\u00a0<strong>Insert &gt; Field<\/strong>;\u00a0<em>Word 2007<\/em>:\u00a0<strong>Insert &gt; Quick Parts &gt; Field<\/strong>. Select\u00a0<strong>StyleRef\u00a0<\/strong>from the list of field names on the left (1), then select the style (e.g.\u00a0<strong>DocAuthor<\/strong>) from the list of style names on the right (2), and click\u00a0<strong>OK<\/strong>\u00a0(3).\n<div id=\"attachment_1343\"><img decoding=\"async\" title=\"StyleRef field\" src=\"http:\/\/cybertext.files.wordpress.com\/2009\/01\/styleref02.png?w=490\" alt=\"StyleRef field\" \/>StyleRef field<\/p>\n<\/div>\n<\/li>\n<li>Repeat step 5 for the other StyleRef fields you want to add. Add words, spaces, punctuation etc. between the fields, as required.\n<div id=\"attachment_1344\"><img decoding=\"async\" title=\"Header created from the styles\" src=\"http:\/\/cybertext.files.wordpress.com\/2009\/01\/styleref03.png?w=490\" alt=\"Header created from the styles\" \/>Header created from the styles<\/p>\n<\/div>\n<\/li>\n<li>Voila! Instant header\/footer populated with the document details. And even better \u2014 as soon as you update any of the data in the cells, the header\/footer automatically updates too.\n<div id=\"attachment_1345\"><img decoding=\"async\" title=\"Instant update\" src=\"http:\/\/cybertext.files.wordpress.com\/2009\/01\/styleref04.png?w=490\" alt=\"Instant update\" \/>Instant update<\/p>\n<\/div>\n<\/li>\n<\/ol>\n<p>If you want to see what\u2019s going on behind the scenes, you can always toggle the field codes in the header\/footer to see how it works:<\/p>\n<div id=\"attachment_1341\"><img decoding=\"async\" title=\"Raw field codes\" src=\"http:\/\/cybertext.files.wordpress.com\/2009\/01\/styleref05.png?w=490\" alt=\"Raw field codes\" \/>Raw field codes<\/p>\n<\/div>\n<p>(Thanks to Ken E on the STC Lone Writers discussion list who shared this technique with us.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many corporate documents require you to have a table near the beginning of the document with details such as the author, the date created, a revision number etc. You may also be required to insert some of these details into &#8230; <a class=\"more-link\" href=\"https:\/\/www.wildow.com\/blog\/?p=899\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-899","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=899"}],"version-history":[{"count":2,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/899\/revisions"}],"predecessor-version":[{"id":901,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/899\/revisions\/901"}],"wp:attachment":[{"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}