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

Free Support Forum - aspose.com

Remove SET

Hi There,

I am trying to remove SET fields from my word document.

It removes if SET field is a single line of text.

It is not removing if SET field is a multi line of text (Paragraphs or Table in it).

I have attached my test project for your reference. I am using version of Aspose.Words.dll

Thanks for your help in advance.

  • John

Hi John,

Thanks for your inquiry. Please use the Field.Remove method to remove the field from the document. See the following highlighted code below. Please let us know if you have any more queries.

List<Person> persons = new List<Person>();

persons.Add(new Person


Name = "John Done",

Age = "35",

Address = "123 Main St, Houston, TX 77002"


persons.Add(new Person


Name = "Bill Gates",

Age = "65",

Address = "8484 59 Hwy, Houston, TX 77002"


persons.Add(new Person


Name = "Will Smith",

Age = "45",

Address = "95959 Hollywood St, Houston, TX 77002"


var dt = new DataTable("Person");




foreach (var item in persons)


var dr = dt.NewRow();

dr[0] = item.Name;

dr[1] = item.Age;

dr[2] = item.Address;



DataSet ds = new DataSet();


Document doc = new Document(MyDir + "TableSet.docx");


NodeCollection starts = doc.GetChildNodes(NodeType.FieldStart, true);

//Loop though all field starts

foreach (FieldStart start in starts)


if (start.FieldType == FieldType.FieldSet)





//Remove SET Fields

//RemoveUnwantedField(doc, FieldType.FieldSet);


doc.Save(MyDir + "TableSet - Output.docx");

Thank you Tahir.. That worked.

Hi John,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.