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

Free Support Forum - aspose.com

Modify merged document

Hello,

I try to modify a saved document, I merge before with a Aspose.

How can I retreive position in document?
Text I have to change, is in table but I don’t known how can I retreive tables in document from node, section or paragraph.
I think, I can’t use DocumentBuilder in this case.

I send you sample: I need to modify cell afer “Déjà réglé” and “Reste à payer”.

Thanks for your help.
Laurent

Hi
Thanks for your inquiry. Please see the following link to learn more about Aspose.Words.Document object model.
https://docs.aspose.com/words/net/aspose-words-document-object-model/
In your case you can use the following code

// Open document and create DocumentBuilder
Document doc = new Document(@"Test154\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Move document builder to table cell
builder.MoveToCell(4, 1, 1, 0);
// Remove old value
CompositeNode cell1 = (Cell)builder.CurrentNode.GetAncestor(NodeType.Cell);
foreach (Run run in cell1.GetChildNodes(NodeType.Run, true))
{
    run.Text = string.Empty;
}
// Insert new value
builder.Write("This is new value");
// Move cursor to another cell
builder.MoveToCell(4, 2, 1, 0);
// Remove old value
CompositeNode cell2 = (Cell)builder.CurrentNode.GetAncestor(NodeType.Cell);
foreach (Run run in cell2.GetChildNodes(NodeType.Run, true))
{
    run.Text = string.Empty;
}
// Insert new value
builder.Write("This is new value");
// Save output document
doc.Save(@"Test154\out.doc");

Hope this helps.
Best regards.

Thanks for your help, it’s exactly what I need.
It’s very helpfull for me.
Best regards.