Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Table of Contents

Getting Started

About templates and merge fields

A WordWriter template is a Microsoft Word file that contains merge fields. A merge field displays a data source field (for example, a database column name). A merge field is created in Microsoft Word and bound in code to a data source. The data source may be an array, a DataSet, a DataTable, or a DataReader. When you run the code, WordWriter populates the merge fields with data source values. A template may contain multiple sets of merge fields. Each set of fields binds to a single data source. 

Merge field syntax

  • Data source and column names must not include Unicode characters.
  • Data source and column names must begin with a letter (A-Z, a-z).
  • Data source and column names may include the following characters only:
    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_
    Icon

    If you assigned a different data source separator, you can also use a "." in your data source and column names.

  • Spaces are not allowed anywhere in a merge field.
Icon

Use brackets if your column name does not conform to these rules
The exception of these rules is when a column name is enclosed in brackets (for example, «Products.[Product Category]» . To include spaces or unicode characters in the data source column name, use this format:«DataSource.[Column Name]»
For example: «Employees.[Street Address]» . The [Column Name] format allows you to match any SQL column name exactly. Legal characters within the brackets include every character except parentheses () or brackets [].
When creating these fields with WordApplication or editing the field codes manually, the merge field name must be enclosed in quotes. For example, it should be { MERGEFIELD "[data source].[column name]" }. Any modifiers must also go in the quotes, but the formatting options must go after the quotes.

Setting up the Template

Adding Styles

Adding a WordWriter Reference in Visual Studio

Writing the Code

Final Code

Downloads

Next Steps

  • No labels