Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents

Table of Contents

Creating a

...

Merge Field

...

Creating a Merge Field

Excerpt

OfficeWriter's WordTemplate object opens a WordWriter template file, populates it with data from one or more data sources, and generates a new Word file. A WordWriter template is a file created in Microsoft Word that

...

contains merge fields. A merge field displays a data source field name (for example, a database column name) where a data source value will be inserted. Merge fields are bound to a data source in OfficeWriter code. When you run the code, OfficeWriter replaces the merge fields with values from the data source and creates a new Word file.

WordTemplate's SetDataSource method binds the merge fields to a data source, which may be an array or a database table record. The Process method enters values from the data source in the template's merge fields.

...

  1. In Microsoft Word, open or create a document to use as your WordWriter template.
  2. Create a text fragment, a list, or a table row that contains merge fields. For example:
  3. Select the text, list, or table row that you want to define as a repeat block. For example:
  4. Open the Insert menu and select Bookmark... to open the Bookmark dialog.
  5. Enter a bookmark name and click Add.

...

Info

The Main Document and Repeat Blocks\
A WordWriter template may include merge fields in repeat blocks, merge fields in the main document, or both. The "main document" is any part of the template that is not within a repeat block. Merge fields within the main document are bound to a data source by the method SetDataSource. Merge fields within repeat blocks are bound to a data source by the method SetRepeatBlock.

...

  1. In Microsoft Word, open or create a document to use as your WordWriter template.
  2. Create a text fragment, a list, or a table row that contains merge fields. For example:
  3. Insert Next fields where you would like the data source to move to the next row when it hits a repeat of the same merge fields.

...

  1. In Microsoft Word, open or create a document to use as your WordWriter template.
  2. From the View menu, select Toolbars -> Mail Merge.
  3. Click the Open Data Source icon.
  4. Select a database. For example, open the Access database Northwind.mdb, located in WordWriter\doc-samples\samples\database.
  5. Select a database table from the list.
  6. Click the Insert Merge Fields icon.
  7. From the Fields list, select a field (a column name) and click Insert. Repeat to add additional fields to the template.
  8. To format a merge field, right-click the merge field and select Edit field... to open the Field dialog. For more information about the Field dialog, see Creating a Merge Field.

Anchor
envelope
envelope

Example: Creating an Envelope Template

...

  1. Open Microsoft Word.
  2. To display the Mail Merge toolbar, open the View menu and select Toolbars -> Mail Merge.
  3. Click the Main document setup icon.
  4. Select Envelopes.
  5. In the Envelope Options dialog, select envelope size, address fonts, and printing options.
  6. Enter merge fields in the envelope's delivery and return address boxes (within the main document). For instructions, see Creating a Merge Field.

Anchor
fax
fax

Example: A Fax Cover Template

...

  1. In Microsoft Word, open the File menu, and select New...
  2. From the New Document window, select General Templates...
  3. In the Templates dialog, select the Letters & Faxes tab.
  4. Select one of the available fax templates.
  5. Insert merge fields in the template.

Anchor
letter
letter

...