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

Free Support Forum - aspose.com

How to replace autodate in a word file using aspose.words

How to replace autodate in a word file to [AutoDate] text using aspose.words?


Thanks for your inquiry. Could you please attach sample document for testing. Input document and expected output document created manually. I will investigate the issue and try to help you.

Best regards.


Please find attached the word document.

In the given document there are two places autodate are present. First in the header part and second in the body part.

I want to replace this autodate to a text value [AutoDate]


Thank you for additional information. It seems you meant DATE and TIME fields. I think the following code could help you.

//Open document and create DocumentBuilder

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

DocumentBuilder builder = new DocumentBuilder(doc);

//Get collection of FieldStartNode from document

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

ArrayList dateStarts = new ArrayList();

//Loop through FieldStarts

foreach (FieldStart start in starts)


if (start.FieldType == FieldType.FieldDate || start.FieldType == FieldType.FieldTime)



//Move cursor to the field start position


//Insert [AutoDate] text




//Now we should remove Date and Time fields

foreach (FieldStart start in dateStarts)


Node currentNode = start;

while (currentNode.NodeType != NodeType.FieldEnd)


currentNode = currentNode.NextSibling;





//Save output document


Best regards.