Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

This class represents a merge field in a document. Merge fields are used in WordWriter templates as data placeholders.

Signature
C#C#
Wiki Markup
{description}
{excerpt}This class represents a merge field in a document. Merge fields are used in WordWriter templates as data placeholders.{excerpt}
{signature:C#}
 public sealed class MergeField : Field
Signature
{signature}{signature:vb.net
vb.net
}
Public NotInheritable Class MergeField
		Inherits Field
Remarks

To create a merge field, use Element.InsertMergeFieldBefore or Element.InsertMergeFieldAfter.

The following sample demonstrates creating a merge field at the end of a new document and retrieving the first merge field of an existing document.

{signature}
{remarks}To create a merge field, use [Element.InsertMergeFieldBefore|Element.InsertMergeFieldBefore(String, String)] or [Element.InsertMergeFieldAfter|Element.InsertMergeFieldAfter(String, String)].

The following sample demonstrates creating a merge field at the end of a new document and retrieving the first merge field of an existing document.

{remarks}
{example}{code:csharp|title=C#}

          //--- Insert a merge field at the end of a new document
          WordApplication app = new WordApplication();
          Document doc = app.Create();
          MergeField mfield = doc.InsertMergeFieldAfter("FieldName", "FieldName");

          //--- Get the first merge field of an existing document
          WordApplication app = new WordApplication();
          Document doc = app.Open(@"C:\sample.doc");
          MergeField firstMergeField = doc.GetElements(Element.Type.MergeField)[0];
        
{code}
{code:vb.net
|title=vb.net
}

          '--- Insert a merge field at the end of a new document
          Dim app As New WordApplication()
          Dim doc As Document = app.Create()
          Dim mfield As Field = doc.InsertMergeFieldAfter("FieldName", "FieldName")

          '--- Get the first merge field of an existing document
          Dim app As New WordApplication()
          Dim doc As Document = app.Open("C:\sample.doc")
          Dim firstMergeField As MergeField = doc.GetElements(Element.Type.MergeField)(0)
        
Example
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle
Methods

...

Name

...

Description

...

GetFieldName()

...

{code}

{example}
{methods}
||Name||Description||
|[GetFieldName()|MergeField.GetFieldName()

...

]|{excerpt-include:MergeField.GetFieldName()

...

|nopanel

...

=true}|