officefileapi-15298-word-processing-document-api-fields-field-codes-seq.md
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. |
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();
}
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