Please help me!Sepearte Document whiledoing Mail MErge


#1

Hai,

This is radha from Singapore.

Again I have Changed my code for Seperating Indivaidual Documents(One Record per Document).Now Iam using Dataset.
I need Seperate Documents for putting into one folder.For Displaying I need One Document(One Record Per page) .
While using,Dataset its displaying different records.But In that Doccument Same Record Only displaying means alldocuments has same content.


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;

string strMMdispFile = Request.PhysicalApplicationPath + “Reminders/RemindersOutput/”+ StrReportName;

Word word = new Word();

Document doc = word.Open(strTemplateFile);

DataSet DSMM= ClsRmdr.GetMMData();

for ( i = 0; i< Convert.ToInt32(DSMM.Tables[0].Rows.Count) ; i++)

{

StrSplit ="";

string SysDate = Convert.ToDateTime(DSMM.Tables[0].RowsIdea[“Trans_Date”].ToString()).ToString(“dd/MM/yyyy”);

string PersonName = DSMM.Tables[0].RowsIdea[“Person_Name”].ToString();

string DeptName = DSMM.Tables[0].RowsIdea[“Dept_Name”].ToString();

string HRN = DSMM.Tables[0].RowsIdea[“HRN_ID”].ToString();

string PatName = DSMM.Tables[0].RowsIdea[“Pat_Name”].ToString();

string ReqName = DSMM.Tables[0].RowsIdea[“Req_Name”].ToString();

string RptName = DSMM.Tables[0].RowsIdea[“Rpt_Name”].ToString();

string Date1 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea[“Date1”].ToString()).ToString(“dd/MM/yyyy”);

string Date2 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea[“Date2”].ToString()).ToString(“dd/MM/yyyy”);

string Date3 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea[“Date3”].ToString()).ToString(“dd/MM/yyyy”);

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;

}

if (RDOC01.Checked == true)

doc.MailMerge.Execute(

new string[] {“SysDate”,“DocName”,“DeptName”,“PatName”,“HRN”,“Req”,“RptName”,“DesDate”,“DueDate”,“EndDate”,“DueDate1”},

new object[] {SysDate,PersonName,DeptName,PatName,HRN,ReqName,RptName,Date1,Date2,Date1,Date3});

//In the above line displaying different name,but merging with different name.//For
Ex Person Name its displaying as “JANAk Jo”.But it mail merge with previous Record Data “NAIR”

doc.Save(strMMfile, SaveFormat.FormatDocument);

}



Can you please help me.I need to do with in this week.