Hello Friends,
I am working on mailmerge and for some reason i want to change the mailmerge field name by editing the document.
my mailmerge "FIELD_NAME" in document.xml looks like
<w:bookmarkStart w:id="0" w:name="_GoBack" />
<w:p w:rsidR="009C1457" w:rsidRDefault="00E2058F">
<w:r>
<w:fldChar w:fldCharType="begin" />
</w:r>
<w:r>
<w:instrText xml:space="preserve"> REF F121_1 \* MERGEFORMAT </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="separate" />
</w:r>
<w:r>
<w:rPr>
<w:noProof />
</w:rPr>
<w:t>«FIELD_NAME\»</w:t>
</w:r>
<w:r>
<w:fldChar w:fldCharType="end" />
</w:r>
<w:r>
<w:fldChar w:fldCharType="begin" />
</w:r>
<w:r>
<w:instrText xml:space="preserve">SET F121_1 "\«FIELD_NAME\»" \* MERGEFORMAT </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="separate" />
</w:r>
<w:bookmarkStart w:id="1" w:name="F121_1" />
<w:r>
<w:rPr>
<w:noProof />
</w:rPr>
<w:t>«FIELD_NAME\»</w:t>
</w:r>
<w:bookmarkEnd w:id="1" />
<w:r>
<w:fldChar w:fldCharType="end" />
</w:r>
</w:p>
<w:bookmarkEnd w:id="0" />
Now using FieldLocator module i can easily list all my fields but i can not change the field names (shown red above)of these fields.
There are method available for traversing on a field and getting it's content like
//FieldRef fr
R r = fr.getBeginRun();
List<Object> objects = r.getContent();
but there isn't any method exposed for setting this content.
There is nothing available about FieldLocator module as it's not released yet. Is there any way to do this? or is there any other way to do this. i want to avoid a direct path search.
Thanks,
Arpit