Click here to Skip to main content
15,921,212 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want do , when we enter text in textfield then on button click event all data should be enter in word file. what we do for enter all data in word file from that textfield .
Posted
Updated 29-May-12 22:15pm
v2
Comments
Maciej Los 29-May-12 16:02pm    
What have you done so far?
Nelek 29-May-12 17:31pm    
Waht is your question? Where are you having problems?

1 solution

Hi, .check my code:

C#
using Word=Microsoft.Office.Interop.Word;
            object oMissing = System.Reflection.Missing.Value;
            object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */

            //Start Word and create a new document.
            Word._Application oWord;
            Word._Document oDoc;
            oWord = new Word.Application();
            oWord.Visible = true;
            oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
                ref oMissing, ref oMissing);
            //Insert a paragraph at the beginning of the document.
            Word.Paragraph oPara1;
            oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
            oPara1.Range.Text = ;  // Here target your text, link to your textfield
            oPara1.Range.Font.Bold = 1;
            oPara1.Format.SpaceAfter = 24;    
            oPara1.Range.InsertParagraphAfter();


Below I add a link for more word automate skills : Summarize C# Control Word Skills[^] Have a check.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900