Using Template Bookmarks for Automating Microsoft Word Reports
Abstract:
A C# method is discussed for using bookmarks in Microsoft Word templates to automate reports. Automating reports using templates can enable the user or client to include custom designs and information. For example, the companys logo design can be put into the template header. Each client can have their own template report style. However, some information may need to be placed in specific locations in the report, or there may be user input to insert, that is only known just prior to the report being generated, and this is where bookmarks can be used. In the above example report, bookmarks were placed into the template for the test date, subtitle, project no., test method, customer, engineer/technician, and the information in the Test Setup table. A template can be designed in Microsoft Word and bookmarks inserted at the desired locations. The report maker application can then read the bookmarks from the template and insert the text at the bookmark location. Some known information, like the current date can be inserted automatically, or for specific user information, a textbox dialog can prompt the user for the text to be inserted for each bookmark field. When a bookmark is defined in Word it must be given a name, and these names can be used as textbox labels to identify each bookmark.