Free Support Forum - aspose.com

How to get the DOCVariable field names

Hi,

i need to get the DOCVariable field names from the word document.Please let e know hoe to do it

Hi

Thanks for your inquiry. You can try to use the following code snippet to achieve this.

Document doc = new Document(@"338_101649_raviteja\in.doc");

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

foreach (FieldStart start in collection)

{

if (start.FieldType == FieldType.FieldDocVariable)

{

string name = (start.NextSibling as Run).Text;

name = name.Replace(" DOCVARIABLE ", "");

name = name.Substring(0, name.IndexOf(" \\"));

}

}

I hope that this will help you.

Best regards.