Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

WordField

OfficeIMO.Word

Namespace
OfficeIMO.Word
Assembly
OfficeIMO.Word
Source revision
0eef6a5756b9 with working tree changes

Represents a field element within a Word document.

Inheritance

Usage

Explore 16 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Methods

AddField 3 overloads
public static WordField AddField(WordParagraph paragraph, WordFieldType wordFieldType, WordFieldFormat? wordFieldFormat = null, string? customFormat = null, bool advanced = false, List<string>? parameters = null) #

Inserts a field into the specified paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
Paragraph to add the field to.
wordFieldType OfficeIMO.Word.WordFieldType required
Type of the field.
wordFieldFormat OfficeIMO.Word.WordFieldFormat? = null optional
Optional field format.
customFormat string? = null optional
Custom format string for date or time fields.
advanced bool = false optional
Whether to use advanced field representation.
parameters System.Collections.Generic.List<string>? = null optional
Additional switch parameters.

Returns

WordField The created field.
public static WordField AddField(WordParagraph paragraph, WordFieldCode fieldCode, WordFieldFormat? wordFieldFormat = null, string? customFormat = null, bool advanced = false) #

Inserts a field represented by a WordFieldCode into the specified paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
Paragraph to add the field to.
fieldCode OfficeIMO.Word.WordFieldCode required
Field code instance describing instructions and switches.
wordFieldFormat OfficeIMO.Word.WordFieldFormat? = null optional
Optional field format.
customFormat string? = null optional
Custom format string for date or time fields.
advanced bool = false optional
Whether to use advanced field representation.

Returns

WordField The created field.
public static WordField AddField(WordParagraph paragraph, WordFieldBuilder builder, bool advanced = false) #

Inserts a field constructed using WordFieldBuilder.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
Paragraph to add the field to.
builder OfficeIMO.Word.WordFieldBuilder required
Field builder instance.
advanced bool = false optional
Whether to use advanced field representation.

Returns

WordField The created field.
public void Remove() #

Deletes all runs and simple field elements associated with this field.

public void ReplaceWithText(string text) #

Replaces the current field with plain text.

Parameters

text string required
Text to insert in place of the field.

Properties

public WordParagraph Paragraph { get; } #

Gets the containing paragraph handle for continuing paragraph authoring.

public WordFieldType? FieldType { get; } #

Gets the type of the current field.

public IReadOnlyList<WordFieldFormat> FieldFormat { get; } #

Gets the format switches applied to the field.

public List<string> FieldSwitches { get; } #

Gets the raw switch parameters from the field code.

public List<string> FieldInstructions { get; } #

Gets the instructions portion of the field code.

public string Field { get; } #

Gets the raw field code.

public bool UpdateField { get; set; } #

Gets or sets a value indicating whether the field is marked dirty.

public bool LockField { get; set; } #

Gets or sets a value indicating whether the field is locked.

public string Text { get; set; } #

Gets or sets the display text of the field.