This is Radha from Singapore.
I can create a Merge file from the Dataset.I need seperate document for seperate record.So I have used below code in C#.
string strTemplateFile =Request.PhysicalApplicationPath + "Reminders/Templates/"+ StrReportName;
string strDatafile =Request.PhysicalApplicationPath + "Reminders/Data/"+ StrReportName.Replace(".doc",".dat").Trim();
string strMMfile =Request.PhysicalApplicationPath + "Reminders/RemindersOutput/"+ StrReportName;
Word word = new Word();
Document doc = word.Open(strTemplateFile);
//Fill the fields in the document with user data.
ClsRmdr.SortFiled="SysDate";
DataSet DSMM= ClsRmdr.GetMMData();---> Dataset contains data from executing Stored Procedures
for ( r = 8; r< Convert.ToInt32(DSMM.Tables[0].Columns.Count) ; r++)
{
mycol= new DataColumn();
mycol.DataType = System.Type.GetType ( "System.String" );
mycol.ColumnName = DSMM.Tables[0].Columns[r].Caption.ToString();
MyDT.Columns.Add ( mycol );
}
for ( i = 0; i< Convert.ToInt32(DSMM.Tables[0].Rows.Count) ; i++)
{
int x=0;
MyRow= MyDT.NewRow();
for ( int j = 8; j < Convert.ToInt32(DSMM.Tables[0].Columns.Count.ToString()) ; j++)
{
MyRow[x]= DSMM.Tables[0].Rows.ItemArray[j].ToString();
x++;
}
MyDT.Rows.Add(MyRow);
strMMfile =Request.PhysicalApplicationPath + "Reminders/RemindersOutput/";
StrSplit = StrReportName.Substring(0,(StrReportName.Length)-4);
if (i == 0)
{
StrSplit = StrSplit + "-01"+".doc";
strMMfile = strMMfile + StrSplit;
}
else
{
Count = Count + 1;
StrSplit = StrSplit + "-0" + Convert.ToString(Count)+".doc";
strMMfile = strMMfile + StrSplit;
}
doc.MailMerge.Execute(MyDT);
doc.Save(strMMfile, SaveFormat.FormatDocument);
I got seperate two Individual files.But both Document contains same data.
Plase help me to do
Please mail me radha_ramgr@yahoo.com