Mail merge with existing mail merge fields

K

-kve-

Hi, I'm trying to perform a mail merge (C#, Office 2003/2007)

I started from th ecode given in http://support.microsoft.com/kb/301659, and
this code works fine.

But the problem is: this example creates and inserts the mail merge fields
by code, and I need to use the fields that are already present in a document
(defined in Word).
On mailMerge.Execute(ref oFalse) I always get the error:"Word could not
finish merging these documents or inserting this database"

Any help would be great...
 
D

Doug Robbins - Word MVP

Without seeing all of the code that you are using, it would be like shooting
in the dark to try and tell you what is causing the problem.

The code in the article that you referenced, creates the datasource as well
as the mail merge main document and while it saves and closes the datasource
as C:\\DataDoc.doc, I cannot see where it attaches that datasource to the
mail merge main document it creates unless it is done by this bit of code

// Create a MailMerge Data file.
CreateMailMergeDataFile();

I should add that I know zilch about C#

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
K

-kve-

Well, the only difference between my code and the code from the article lies
in the fact that in the article, the merge fields are created at runtim (in
code), and I don't do that (because I use a document that already has the
necessary fields)
 
D

Doug Robbins - Word MVP

As I said, I do not see in that code where the data source is being attached
to the mail merge main document. Are you creating the data source on the
fly as is being done in that code? Or do you have an existing data source.

I believe that the command to attach the datasource to the mail merge main
document may be missing from the code in that article

I would expect to see a command somewhere along the lines of

wrdMailMerge.OpenDataSource

Sorry I can't help you withe exact C# command, but for the VBA syntax, check
out the OpenDataSource item in the Visual Basic Editor.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top