Faq/Writer/045

    From The Document Foundation Wiki
    < Faq‎ | Writer

    How do I insert a variable to enter information into a document?

    Variables are managed by fields:

    • select the Insert ▸ Field ▸ More Fields... menu (or Ctrl + F2); and
    • select the Variables tab

    To be able to use a variable, the variable must have an existence at the insertion point. In other words, the definition of the variable must precede its use, and therefore be placed before in the text, if it is empty. A variable can have multiple values ​​along the document.

    Define a variable

    • select the field type Set variable;
    • fill the name and the value at the bottom of the dialog box;
    • select the format. To display a character string, select Text; and
    • click Insert then Close.

    It is possible to place this field at the beginning of the document and then check Invisible; afterwards you can use this variable anywhere in the text.

    Resetting a variable allows its value to be modified.

    Create an input field to modify the value of this variable later in the text

    • select the field type Input field;
    • select the variable you want;
    • add an annotation that will give information to fill the field;
    • click Insert; and
    • fill in a default value and click OK, then Close.

    This will insert a field. When it is clicked, its value is prompted for. It will be changed in all uses of the variable downstream of the input field, but not for positions upstream.

    Use this variable again later in the document

    • select the field type Show variable;
    • select the field you want to use; and
    • click the Insert button then Close.

    The value shown is the value previously set in the text.

    Delete a variable

    • delete all the setting and input fields for the variable in the text using the Del key;
    • open the variable dialog box (Insert ▸ Field ▸ More Fields... ▸ Variables [tab] menu);
    • select the field type Set variable;
    • select the variable you want to delete;
    • click the red cross. If the red cross is not available, that means that some settings or input fields for the variable are still present in the text.

    There exists a particular type of variable: the user field, described in this question.