We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Mergefields

Hey,

I'm evaluating DocIO for a project we're working on that needs a extensive Word-link. At first sight it looks very intresting.
We want to let our customers create documents from our data. There are 2 steps : first they create the template, after that they use the templates to merge.
For the template creation I would like to present them with an empty document that has all possible MergeFields allready defined since we have them in a database already (100+ fields, so impossible to define manualy every time).
Can I do this with DocIO ? I didn't find an example to add a defination of mergefield yet.

Thanks for the help
Xavier, CPS


10 Replies

BP Bhuvaneswari P Syncfusion Team September 12, 2008 01:15 PM UTC

Hi Xavier,

Thank you for evaluating Syncfusion Essential DocIO.

Yes, it is possible to insert merge field using the DocIO API's by using the Paragraph.AppendField() method. You can insert any field using this method like CreateDate, Formfields and etc.. Please refer the below code snippet to do so:
[C#]

paragraph.AppendText("FirstName=");
//Insert MergeField
paragraph.AppendField("FirstName", FieldType.FieldMergeField);
paragraph.AppendText("LastName=");
//Insert MergeField
paragraph.AppendField("LastName", FieldType.FieldMergeField);


Here is the sample for your reference:

http://websamples.syncfusion.com/samples/DocIO.Windows/F76550/main.htm


Please try this and let us know if you need any further assistance we glad to assist to you.

Best Regards,
Bhuvana




NX Nuyttens Xavier September 12, 2008 02:49 PM UTC

Bhuvana,

Thanks for your help, but I don't think this is what I was looking for.

I want users to be able to create the template and select the fields from the Word mergefields list. We had something like that in the previous application we wrote in Foxpro and automated with Office directly. I think it was achieved by connecting the datasource to the document without executing the mergefunction. That way you work with the fields from datasource in the template and even start the merge from Word itself if you want to.

Greetings
Xavier




BP Bhuvaneswari P Syncfusion Team September 22, 2008 12:52 PM UTC

Hi Xavier,

Thanks for the update.

Please have a look into your sample browser sample which includes all the merge features:
\\Syncfusion\EssentialStudio\X.X.X.X\Windows\DocIO.Windows\Samples\2.0\MailMerge

Online Documentation link:

http://help.syncfusion.com/UG/Reporting/DocIO/Windows%20Forms/Documents/46mailmerge.htm


Please try these features and let us know if you need any further assistance.

Best Regards,
Bhuvana




NX Nuyttens Xavier September 23, 2008 12:01 PM UTC

Bhuvana,

I have looked at your samples and played around with the code, but again, there's one big feature I'm missing : ability to open the document (template) with the datasource connected BEFORE the mailmerge is executed.
I added an example of what I'm trying to achieve.

Greetings
Xavier



NX Nuyttens Xavier September 23, 2008 12:02 PM UTC

Bhuvana,

I have looked at your samples and played around with the code, but again, there's one big feature I'm missing : ability to open the document (template) with the datasource connected BEFORE the mailmerge is executed.
I added an example of what I'm trying to achieve.

Greetings
Xavier



NX Nuyttens Xavier September 23, 2008 12:03 PM UTC

Bhuvana,

I have looked at your samples and played around with the code, but again, there's one big feature I'm missing : ability to open the document (template) with the datasource connected BEFORE the mailmerge is executed.
I added an example of what I'm trying to achieve.

Greetings
Xavier



MailMerge_53fe72a.zip


BP Bhuvaneswari P Syncfusion Team September 24, 2008 12:49 PM UTC

Hi Xavier,

Thanks for the update.

I could find only one screenshot there is no sample. Could you please send me the sample?

Best Regards,
Bhuvana



AD Administrator Syncfusion Team December 23, 2008 05:25 PM UTC

Xavier,

Looking through this thread, it appears that the screenshot you provided is some kind of Word plugin you had created that allows your end-users to select the fields they want inserted while creating a "mail merge template" in Word.

If so, DocIO, does not help you in any way to create such a plug-in for Word.

Once the template is created though, as you probably know already, DocIO can perform the mail merge.

Also if you want your end-users to create a template using Word, that has to be done outside the scope of DocIO.

If we are missing something please let us know.

Thanks
Praveen




NX Nuyttens Xavier January 5, 2009 08:29 AM UTC

Hi,

No I did not create a plugin of any kind. All I did was create a datasource, open the Word document and connect the datasource. At this moment Word lets you choose the fields since it knows what fields are available.

Greetings
Xavier, CPS

>Xavier,

Looking through this thread, it appears that the screenshot you provided is some kind of Word plugin you had created that allows your end-users to select the fields they want inserted while creating a "mail merge template" in Word.

If so, DocIO, does not help you in any way to create such a plug-in for Word.

Once the template is created though, as you probably know already, DocIO can perform the mail merge.

Also if you want your end-users to create a template using Word, that has to be done outside the scope of DocIO.

If we are missing something please let us know.

Thanks
Praveen






BP Bhuvaneswari P Syncfusion Team January 6, 2009 12:40 PM UTC


Hi Xavier,

Thanks for the update.

Yes, it's possible to take a list of fields from the word document and also it is possible to insert the merge fields into the document using DocIO.

Code snippet to get the merge fields from the document:
string[] s = doc.MailMerge.GetMergeFieldNames();

Code snippet to insert fields into the word document:
doc.LastParagraph.AppendText("FirstName");
WField field= doc.LastParagraph.AppendField("FirstName", FieldType.FieldMergeField) as WField ;

Sample link:
http://www.syncfusion.com/uploads/redirect.aspx?file=DocIO_MailMerge_6bc94ab9.zip&team=support

sample description: 1. The existing document merge fields displayed in the listbox
2. select fields and click "Addfield" button to add the field into another document
3. After added all the fields click "create doc" button will create the document with that fields.

Please let me know if this meets your requirement.

Best Regards,
Bhuvana



Loader.
Live Chat Icon For mobile
Up arrow icon