Message-ID: <65419728.10039.1711710585407.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_10038_1002256628.1711710585407" ------=_Part_10038_1002256628.1711710585407 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Field

Field

Description

=20

This class is a low level representation of a field. This encompasses ma= ny objects in Word, such as merge fields, hyperlinks, TOC entries, etc. Fie= lds are the generic form of what are contained in a Element's inline elemen= ts.

=20
C#
=20
 public class Field : Element
=20
=20
vb.net
=20
Public Class Field
=09=09Inherits Element
=20
=20

Remarks

=20

To create a field, call the corresponding "insert" method for = what you want to create (hyperlink, TOC entry, etc) on an Element or Position object.

=20

To get an existing field, use the Element.GetElements() method and pass in= the Element.Type.Field parameter to retrieve all fields.

=20

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

=20

Examples

=20
C#
=20

          //--- Insert a field at the end of a new document
          WordApplication app =3D new WordApplication();
          Document doc =3D app.Create();
          Field fld =3D
               doc.InsertHyperlinkAfter("http://www.softartisans.com&q=
uot;, "SoftArtisans");

          //--- Get the first field of an existing document
          WordApplication app =3D new WordApplication();
          Document doc =3D app.Open(@"C:\sample.doc");
          Field firstField =3D doc.GetElements(Element.Type.Field)[0];
        
=20
=20
vb.net
=20

          '--- Insert a field at the end of a new document
          Dim app As New WordApplication()
          Dim doc As Document =3D app.Create()
          Dim fld As Field =3D _
               doc.InsertHyperlinkAfter("http://www.softartisans.com&q=
uot;, "SoftArtisans")

          '--- Get the first field of an existing document
          Dim app As New WordApplication()
          Dim doc As Document =3D app.Open("C:\sample.doc")
          Dim firstField As Field =3D doc.GetElements(Element.Type.Field)(0=
)
        
=20
=20

Properties

=20
=20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20

Name

Description

Code<= /p>

Returns a String that represents th= is field's code.

Conte= nts

Returns an Elem= ent object that represents the contents of this field.

Type<= /p>

Returns a Field.FieldType object that represents this field's type.
=20

Methods

=20
=20 =20 =20 =20 =20 =20 =20 =20 =20

Name

Description

Update()

Updates the value of the field.
=20

Nested Classes

=20
=20 =20 =20 =20 =20 =20 =20 =20

Name

Description

Fiel= dType

The Field cla= ss is a general representation that encompasses many Word objects, includin= g merge fields, hyperlinks, and table of contents items. A Field.FieldType value specifies the type of fi= eld a specific Field object represents.<= /td>=20
------=_Part_10038_1002256628.1711710585407--