Programmatically add Database fields list to select Merge Fields

Varun Arora 6 Reputation points
2021-11-11T03:08:22.46+00:00

Hello,

In our system we give ability to provide user to add merge fields in MS Word templates, so that when actual print/email job is done they can be mapped and copies are created. We have a collection of merge fields for the user to select from (around 100 of them).

Is it possible to attach the list of placeholders(merge fields) to the document so that once the user download the Word doc and select the merge field to be added to the template programmatically(C#)?

Something like attached screenshots. Either in Database Fields or Merge Fields.148390-insertfield-mergefield.png
148443-databasefields-mailmerge.png

Thanks in Advance.

Regards,
Varun

Microsoft 365 and Office Word For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Hua-MSFT 27,796 Reputation points
    2021-11-11T09:57:46.823+00:00

    Hi @Varun Arora ,

    > Is it possible to attach the list of placeholders(merge fields) to the document so that once the user download the Word doc and select the merge field to be added to the template programmatically(C#)?

    On your first image, the content that you highlighted are not field names, they are formats. Via Mergefield field from Qucik Parts, you need to enter the field name manually instead of selecting field from a list.

    Do you want to add the fields from database programmatically into the list as the following image shown?
    148488-capture48.jpg
    The list that the image shown is from the Recipient List, if you need users to select specific fields when using mail merge function, you could export the fields and their corresponding data as an Excel file, and then import this file as a Recipient List into Word document.
    Under this case, if users download the document, they could instert the merge field that you imported in advance.

    If you just want to get the fields and data from database, maybe you could try to use Field codes: Database field to get the fields from your database.

    Any misunderstandings, please let me know.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.