chrisfcarroll / MailMerge

Merge component for OfficeOpenXml .docx (i.e. Microsoft Word) documents
GNU General Public License v3.0
20 stars 7 forks source link

"Broken" mergefield #7

Closed AllTaken closed 1 year ago

AllTaken commented 4 years ago

The following is from a Microsoft Word document with a mergefield with a fieldname of "SBEH":

    <w:r w:rsidR="007902E4">
        <w:fldChar w:fldCharType="begin"/>
    </w:r>
    <w:r w:rsidR="007902E4">
        <w:instrText xml:space="preserve"> MERGEFIELD  SBEH  \* M</w:instrText>
    </w:r>
    <w:r w:rsidR="007902E4">
        <w:instrText xml:space="preserve">ERGEFORMAT </w:instrText>
    </w:r>
    <w:r w:rsidR="007902E4">
        <w:fldChar w:fldCharType="separate"/>
    </w:r>
    <w:r>
        <w:rPr>
            <w:noProof/>
        </w:rPr>
        <w:t>«SBEH»</w:t>
    </w:r>
    <w:r w:rsidR="007902E4">
        <w:rPr>
            <w:noProof/>
        </w:rPr>
        <w:fldChar w:fldCharType="end"/>
    </w:r>

Unfortunately this does not get merged.

The following is logged: Noting <w:instrText 'SBEH '>...</w:instrText> for replacement with TL Ignored sequence containing System.Xml.XmlElement because it was incomplete

I'm guessing it has something to do with the node containing the "separate" node not being the immediate sibling of the mergefield node, because of the mergefield node being split into two.

I really don't know if this is OK, or if Microsoft are bending the rules, but I really need to merge this document 😅

AllTaken commented 4 years ago

Should be fixed by PR #8

AllTaken commented 3 years ago

Any chance of getting the PR reviewed and/or merged in the near future?

killnine commented 1 year ago

I have noticed this same issue. Very tricky to track down in the document. If this fix works can it be merged?

chrisfcarroll commented 1 year ago

Merged, will publish to nuget shortly

chrisfcarroll commented 1 year ago

https://www.nuget.org/packages/MailMerge/2.5.1