

Templates are documents with a preset format which can be used to begin other documents. This article is based on legacy software. The next step is to be creative with your code and build a solution around the template’s structure.(Legacy) Microsoft Word 2007: Working with Templates When it comes to inserting data using a Word document template, the first step is to build the template structure. It sure works to highlight the two strategies however.

wdAutoFitContent ) Ī key different with this method is we add two columns to the table and set values for the header row.įor production code, the demoType parameter doesn’t make any sense. This is what the findTable function does. We can then loop through all the tables in the document and search for our table. Therefore, the template builder creates tables and insert a name for it the first cell. We can do it in code via the ID property but this is useless to a user building templates. Word doesn’t provide a way for users to name the tables. The findTable functionįirst up, we need a function that finds the desired table. The tables act as placeholders for the data we want to insert. The code for today centers on how to find the tables in the document. Both have two tables but the second page’s tables reside within Word bookmarks. We now have a template document with two pages. After you add both bookmarks, the bookmark dialog box will look like this: You can find the bookmark command in Word’s Insert tab. Be sure to insert the bookmarks as directed.Design the page according to the image below:.Insert a page break to add another page to the Word document.Design the first page according the image below:.

Name the file DataTemplate.dotx because that’s what I named mine. Write down its location because you will need when you test your code. You can save to the location of your choice.
