private static void ReplaceText(string dataDir)
{
// ExStart:ReplaceText
Document doc = new Document(dataDir);
// Get the first table in the document.
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
// Replace any instances of our string in the entire table.
table.Range.Replace("Carrots", "Eggs", new FindReplaceOptions(FindReplaceDirection.Forward));
// Replace any instances of our string in the last cell of the table only.
table.LastRow.LastCell.Range.Replace("50", "20", new FindReplaceOptions(FindReplaceDirection.Forward));
dataDir = RunExamples.GetDataDir_WorkingWithTables() + "Table.ReplaceCellText_out.doc";
doc.Save(dataDir);
// ExEnd:ReplaceText
Console.WriteLine("\nText replaced successfully.\nFile saved at " + dataDir);
}
}