This article describes how to create a new Word document in c#.
follow these steps:
1. Start a new Windows application in c# language.
2. Add a reference to the Microsoft Word Object Library
3. Add a button to Form1 from Toolbox.
4. Double-click Button1, create a Button click event.
5. Write code on the click event of button:
private void CreateWordDocument() { object oMissing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word._Application objWord; Microsoft.Office.Interop.Word._Document objDoc; objWord = new Microsoft.Office.Interop.Word.Application(); objWord.Visible = true; objDoc = objWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); Microsoft.Office.Interop.Word.Paragraph objPara; objPara = objDoc.Content.Paragraphs.Add(ref oMissing); objPara.Range.Text = "Welcome to Author Code"; objPara.Range.Font.Bold = 1; objPara.Format.SpaceAfter = 30; objPara.Range.InsertParagraphAfter(); }