We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Remove Paragraphs of Sequence Number (SEQ) Fields & Captions from Word DOCX Document (C# .NET)

I want delete caption and field,The title before the caption is variable,for example:
Figure,Fig,Table,Tab,TT,Equation
Attached documents is testfile(TestCaption.docx) and explain(target.jpg)TestCaption.zip (54.2 KB)

@lovecomputer,

Please also provide your expected Word DOCX file showing the desired output here for our reference. You can create this file manually by using MS Word. We will then start further investigation into your particular scenario and provide you code to achieve the same output by using Aspose.Words.

this is my expected Word DOCX file
expected.docx (25.6 KB)

@lovecomputer,

You can use following C# code of Aspose.Words for .NET API to remove paragraphs of sequence number (SEQ) fields from Word DOCX document.

Document doc = new Document("C:\\Temp\\TestCaption\\TestCaption.docx");

ArrayList listOfParagraphs = new ArrayList();
foreach (Field field in doc.Range.Fields)
{
    if (field.Type == FieldType.FieldSequence)
    {
        Paragraph parentPara = (Paragraph)field.Start.GetAncestor(NodeType.Paragraph);
        if (!listOfParagraphs.Contains(parentPara))
            listOfParagraphs.Add(parentPara);
    }
}

foreach (Paragraph para in listOfParagraphs)
    para.Remove();

doc.Save("C:\\temp\\TestCaption\\21.7.docx");