First add refrence Microsoft.word 11 from com
or in asp.net
using Microsoft.Office.Interop.Word;
object fileName = "c://MyFile.doc";
object novalue = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.ApplicationClass objWord = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document objWordDoc = objWord.Documents.Add(ref novalue, ref novalue, ref novalue, ref novalue);
objWord.Selection.TypeText("Test Dcument");
objWord.Selection.TypeParagraph();
objWordDoc.SaveAs(ref fileName, ref novalue, ref novalue, ref novalue,
ref novalue, ref novalue, ref novalue, ref novalue, ref novalue,
ref novalue, ref novalue, ref novalue, ref novalue, ref novalue, ref novalue, ref novalue);
objWord.Quit(ref novalue, ref novalue, ref novalue);
You can use C#/.NET Library like Aspose.Words for .NET to create word documents, this library offers many sample codes to be used in any .net application.
ReplyDelete