C#NET2008 Fill Microsoft WORD 2003 Document template with Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    C#NET2008 Fill Microsoft WORD 2003 Document template with Data

    Hullo Good Friends,
    I need your help. Please help me.

    I am using C#NET2008 to develop Window Application to fill Microsoft WORD 2003 Template textbox with data from FORM textbox control input my user then print save and print the WORD Template as Letter to the customer.

    Apparently it is now working as I have not done it before
    This is the error message
    Error 1 The best overloaded method match for 'Word.FormField s.this[ref object]' has some invalid arguments

    This are the codings that generated it:
    oDoc.FormFields["dtxtDatePr int"].Range.Text = DateTime.Now.To ShortDateString ;
    oDoc.FormFields["dtxtCompNa me"]).Range.Text = strCustArray[0];


    Code:
     if (DR.HasRows== true )
         {
                                                       
          object objFileName = strFileNamePath;  // F:\\SaleDepart\\Custfolder\OrderLetter.dot
          object objReadOnly = false;
          object objIsVisible = true;
    
          object oMissing = System.Reflection.Missing.Value;
          Word.Application oWord = new Word.Application();
          Word.Document oDoc = new Word.Document();
          Word.Table oTable;
                        
          oWord.Visible = true;
     
          oDoc = oWord.Documents.Add(ref objFileName, ref oMissing, ref oMissing, ref oMissing);
    
        // template control : dtxtDatePrint, dtxtCompName 
    
             oDoc.Activate();
         Doc.FormFields["dtxtDatePrint"].Range.Text =        DateTime.Now.ToShortDateString;
         oDoc.FormFields["dtxtCompName"]).Range.Text = strCustArray[0];                   
                                    
            }
Working...