Skip to main content

SEQ

  • 2 minutes to read

Non-MailMerge field

{ SEQ identifier [ switches ] }

Sequentially numbers user-defined lists of items in a document. Identifier is the name assigned to the series of items that are to be numbered.

The SEQ field supports the following switches:

Switch Description
\c Repeats the closest preceding sequence number.
\h Hides the field result.
\n Inserts the next sequence number for the specified item. This is the default.
\r number Resets the sequence number to the specified integer number.

Example: Insert the SEQ Field in Code

using (var wordProcessor = new RichEditDocumentServer()) {
    wordProcessor.LoadDocument("Documents//Table of Contents.docx");
    Document document = wordProcessor.Document;
    document.BeginUpdate();

    for (int i = 0; i < document.Images.Count; i++) {
        DocumentImage shape = document.Images[i];
        Paragraph paragraph = document.Paragraphs.Insert(shape.Range.End);

        // Insert caption to every image in the document
        DocumentRange range = document.InsertText(paragraph.Range.Start, "Image ");

        // Mark captions with the SEQ fields
        Field field = document.Fields.Create(range.End, "SEQ  Image \\*ARABIC");
    }
    document.Fields.Update();
    document.EndUpdate();
}