Back to Devexpress

SEQ

officefileapi-15298-word-processing-document-api-fields-field-codes-seq.md

latest2.2 KB
Original Source

SEQ

  • Mar 28, 2025
  • 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:

SwitchDescription
\cRepeats the closest preceding sequence number.
\hHides the field result.
\nInserts the next sequence number for the specified item. This is the default.
\r numberResets the sequence number to the specified integer number.

Example: Insert the SEQ Field in Code

csharp
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();
}
vb
Using wordProcessor = New RichEditDocumentServer()
    wordProcessor.LoadDocument("Documents//Table of Contents.docx")
    Dim document As Document = wordProcessor.Document
    document.BeginUpdate()

    For i As Integer = 0 To document.Images.Count - 1
        Dim shape As DocumentImage = document.Images(i)
        Dim paragraph As Paragraph = document.Paragraphs.Insert(shape.Range.End)

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

        'Mark the captions with the SEQ fields
        Dim field As Field = document.Fields.Create(range.End, "SEQ Image \*ARABIC")
    Next i
    document.Fields.Update()
    document.EndUpdate()
End Using