Issue changing Mergefield names

For some reason, when I change the mergefield names, some issues arrise.

  1. *MERGEFORMAT becomes \m
  2. Quotes appear around the merge name. Unfortunately, salesforce cannot recognize mergefields with quotes around them

Example:
In a document, I can have a mergefiled called «representativename». When I toggle field codes, it looks like:
{ MERGEFIELD representativename \* MERGEFORMAT }
When I run the change routine, it becomes:
{ MERGEFIELD "USER_FULLNAME" \m }
The code we use was taken from this site a while back, so it may be outdated. I modified it slightly to fit the thread…

Dim doc As Document = New Document(inDoc)
Dim fieldStarts As NodeList = doc.SelectNodes("//FieldStart")

For Each fieldStart As FieldStart In fieldStarts
    If (fieldStart.FieldType = FieldType.FieldMergeField) Then
        Dim mergeF As Mergefield = New Mergefield(fieldStart)

        'Code will need to check for current name here, replace if matched.
        If replace(replace(CStr(mergeF.Name), "«", ""), "»", "") = "representativename" Then
            mergeF.Name = "USER_FULLNAME"

        End If
    End If
Next fieldStart
doc.Save(inDoc)
doc = Nothing

Hi

Thanks for your request. I cannot reproduce the problem on my side. I used your code and the latest version of Aspose.Words for testing. You can download the latest version of Aspose.Words from here:
https://releases.aspose.com/words/net
I also attached MergeField class, I used for testing. By the way, it is the same as provided here:
https://docs.aspose.com/words/net/fields-overview/
Also, could you please attach a simple document, which you are using for testing. I will check it and provide you more information.
Best regards.