MergeField class missing

I’m trying to follow the documentation to rename mail merge fields shown here: Fields Overview in C#|Aspose.Words for .NET

However, it seems like there is no MergeField class in the Aspose.Words namespace. Am I missing an additional package, or are the docs out of date? How can I rename mail merge fields?

@ayounger The code example is outdated. Please use the following code to rename merge fields in your document:

Document doc = new Document(@"C:\Temp\in.docx");

foreach (Field f in doc.Range.Fields)
{
    if (f.Type == FieldType.FieldMergeField)
    {
        FieldMergeField mergeField = (FieldMergeField)f;
        mergeField.FieldName = mergeField.FieldName + "_Renamed";
        mergeField.Update();
    }
}

doc.Save(@"C:\Temp\out.docx");
1 Like

It worked! Thank you so much!

1 Like