You can make a document from a template as follows:
priavte void CreateWordDocument(string InputFileNamePath, string OutputFileNamePath) { Application app = new Microsoft.Office.Interop.Word.Application(); doc = app.Documents.Open(InputFileNamePath,ref missing, ref missing,ref Missing, ref Missing); // Activate document doc.Actiavte(); //Find place holders in input template and replace them with database values this.FindAndReplace(app,"<Name>","John"); //take all values from database this.FindAndReplace(app,"<Address>","Test address"); this.FindAndReplace(app,"<City>","Test City"); //Save file doc.SaveAs(ref OutputFileNamePath, ref missing, ref missing, ref missing, ref missing); doc.Close(ref missing,ref missing,ref missing,) }
Visit the link for more help: http://www.techrepublic.com/blog/howdoi/how-do-i-modify-word-documents-using-c/190
user1711092
source share