Creating a mail merge document using C#.

From: campwes (campwes_at_discussions.microsoft.com)
Date: 12/09/04


Date: Thu, 9 Dec 2004 11:27:23 -0800

Hey, all. I'm trying to develop a C# app that creates Word 2003 mail merge
documents with an Oracle 9i database as the datasource. I used the following
as an example of how I can start out:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;301659

The problem is that the code provided doesn't allow me to add more users to
the mail merge data file. When I try to add an additional user with the
following code, I get this error when I try to build:

"No overload for method 'FillRow' takes '6' arguments"

Here's the code I want to work. Please help.

<code>
                private void FillRow(Word._Document oDoc, int Row, string Text1,
                        string Text2, string Text3, string Text4, string Text5)
                {
                        // Insert the data into the specific cell.
                        oDoc.Tables[1].Cell(Row,1).Range.InsertAfter(Text1);
                        oDoc.Tables[1].Cell(Row,2).Range.InsertAfter(Text2);
                        oDoc.Tables[1].Cell(Row,3).Range.InsertAfter(Text3);
                        oDoc.Tables[1].Cell(Row,4).Range.InsertAfter(Text4);
                        oDoc.Tables[1].Cell(Row,5).Range.InsertAfter(Text5);
                }

                private void CreateMailMergeDataFile()
                {
                        Word._Document oDataDoc;
                        int iCount;

                        Object oName = "C:\\DataDoc.doc";
                        Object oHeader = "FirstName, LastName, Address, CityStateZip";
                        wrdDoc.MailMerge.CreateDataSource(ref oName,ref oMissing,
                                ref oMissing,ref oHeader, ref oMissing, ref oMissing,
                                ref oMissing, ref oMissing, ref oMissing);

                        // Open the file to insert data.
                        oDataDoc = wrdApp.Documents.Open(ref oName,ref oMissing,
                                ref oMissing, ref oMissing,ref oMissing,ref oMissing,
                                ref oMissing,ref oMissing,ref oMissing,ref oMissing,
                                ref oMissing,ref oMissing,ref oMissing,ref oMissing,
                                ref oMissing, ref oMissing);

                        for (iCount=1; iCount<=2; iCount++)
                        {
                                oDataDoc.Tables[1].Rows.Add(ref oMissing);
                        }
                        // Fill in the data.
                        FillRow(oDataDoc, 2, "Steve", "DeBroux",
                                "4567 Main Street", "Buffalo, NY 98052");
                        FillRow(oDataDoc, 3, "Jan", "Miksovsky",
                                "1234 5th Street", "Charlotte, NC 98765");
                        FillRow(oDataDoc, 4, "Brian", "Valentine",
                                "12348 78th Street Apt. 214",
                                "Lubbock, TX 25874");
                        FillRow(oDataDoc, 5, "FifthFirst", "FifthLast",
                                "6666 Phoney Street",
                                "Cowtown, CA 90218");
                        // Save and close the file.
                        oDataDoc.Save();
                        oDataDoc.Close(ref oFalse, ref oMissing, ref oMissing);
                }
</code>



Relevant Pages

  • Re: Future of VFP (yet again)
    ... Several years ago they tried to convert it to a web based app, ... central database a thousand miles away. ... > normal Oracle has.. ... > application right through the browser!!! ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Di.ch tie^ng Viet tu+. -do^.ng
    ... Choice of database is important. ... Oracle is widely used but is not intended for novice. ... I assume this is a stand-alone light-weight app. ... this app has to install Oracle Server? ...
    (soc.culture.vietnamese)
  • what to do with a table called EVENT ?
    ... I'm writing a VB.NET 2005 app to display some data from an Oracle 10g ... database that has a table called EVENT. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: What so special about PostgreSQL and other RDBMS?
    ... That's exactly the link the licence agreement for the database points to when it ... comes to what wecan expect for paying support. ... > "Oracle may provide additional releases or versions of its programs ... If the requirements are volatile I'd do a long term contract detailing what ...
    (comp.lang.php)
  • Re: Portable Database Choice
    ... I searched this group quite a bit looking for database alternatives and did find the options below from this search. ... I'm posting this in the hope it can be of use to other developers in a position similar to mine where I needed a low cost alternative to Pocket Access. ... One app requires synchronization between desktop and mobile device, the other requires a push of data from the desktop to mobile. ...
    (microsoft.public.dotnet.framework.compactframework)