Merging with Dataview


Can you please tell me what I’m doing wrong here. The code works, it opens the template, creates the file, and then opens the file but does not do the data merge. Here is the code I have:

private void New_Active_DataView()


objDataViewClientActive = objDataSet.Tables[“Client”].DefaultView;

objDataViewClientActive.RowFilter = “IsNull(TERM_DATE, ‘01/01/1900’) = ‘01/01/1900’”;

Document doc = OpenDoc(“OccupancyList.doc”);


string strFileNameMerge = “NPF.doc”;




ShellExecuteA(0,“open”, strFileNameMerge, null, null, 2);


private Document OpenDoc(string fileName)


Word app = new Word();

return app.Open(fileName);


Any help would be most appreciated



I notice you call ExecuteWithRegions. First, check that this is indeed what you want. You need to use regions if you want to grow a part inside a document. If you just want to merge whole content of the document for every record you don’t need to use merge regions.

When you use ExecuteWithRegions, the document must contains the appropriate mail merge region(s). This function will not insert data into merge fields that are outside of mail merge regions.

In your case you need to designate start and end of a mail merge region by inserting two merge fields with special names TableStart:Client and TableEnd:Client.


Thanks, that worked, but now it only gives me one line per page as opposed to a list of all the clients in the dataview, could you point me in the right direction on that? (I apologize if this is a mail merge thing that I don’t know about but I searched the office help/google and couldn’t find anything)

Thanks again for your help.


Figured it out, thanks anyway. I though i would be smart and just change the executeregions to execute but that is what causes it to be one per page. Using ExecuteRegions with the tablestart & table end tags works perfectly.

Thanks again!