---
name: "MsOffice::Word::Surgeon::Field"
section: "3pm"
platform: "linux"
package: "libmsoffice-word-surgeon-perl"
version: "2.10-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/MsOffice::Word::Surgeon::Field"
---

# MsOffice::Word::Surgeon::Field(3pm)

internal representation for a MsWord field

## NAME

MsOffice::Word::Surgeon::Field - internal representation for a MsWord field

## DESCRIPTION

This is used internally by MsOffice::Word::Surgeon for storing a MsWord field.

## METHODS

### new

```
  my $field = MsOffice::Word::Surgeon::Field(
    xml_before  => $xml_string,
    code        => $code_instruction_string,
    result      => $xml_fragment,
    status      => 'begin',
  );
```

Constructor for a new field object. Arguments are :

- xml\_before

  A string containing arbitrary XML preceding that field in the complete document. The string may be empty but must be present.

- code

  A code containing the instruction string for that field. If the instruction string contains embedded fields, these are represented through the "show\_embedded\_field" in MsOffice::Word::Surgeon syntax -- by default, just a pair of curly braces.

- result

  An XML fragment corresponding to the last update of that field in MsWord.

- status

  One of `"begin"`, `"separate"`, or `"end"`.

  Status `"begin"` or `"separate"` are intermediate, used internally during the parsing process. Normally all fields are in `"end"` status.

### add\_to\_code

While parsing fields, additional field instruction fragments are added through this method

### add\_to\_result

While parsing fields, additional XML fragments belonging to the field result are added through this method

### type

The first instruction in the `"code"` part, eg `"REF"`, `"QUOTE"`, `"ASK"`, `"DOCPROPERTY"`, etc. Note : in the Microsoft Word Object Model, the \<https://learn.microsoft.com/en-us/office/vba/api/word.field.type\|Field.Type\> attribute is an integer value in an enumerated type. Here the attribute is just an uppercase string. Lists of valild field types can be found in the Word documentation.

## AUTHOR

Laurent Dami, \<dami AT cpan DOT org\<gt\>

## COPYRIGHT AND LICENSE

Copyright 2024 by Laurent Dami.

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
