G
Guest
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>
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>