Skip to content

C#NET2008 problem with Microsoft WORD 2003

Lennie Kuah

Asked Oct 9, 2010, 11:50 PM EDT2 answers
Share
LinkedInX
Hullo my Good Friends,
I need your help again. Please help me.
I am trying to use C#NET2008 and Microsoft WORD 2003 to develop Window Application  to print the Sales Transaction statement. But it not working.
This coding create the error message list below

 objWord = new Microsoft.Office.Interop.Word.Words();  <--- Error

 

Error Message:

Error 1 Cannot create an instance of the abstract class or interface 'Microsoft.Office.Interop.Word.Words'

 

Here are the coding:

C#
 
using Microsoft.Office.Core;using Microsoft.Office;using Microsoft.Office.Interop.Word; namespace CSharpDelegatePractice{    public partial class FrmCustomerMaint : Form    {          private Microsoft.Office.Interop.Word.Words  objWord;          private Microsoft.Office.Interop.Word.Document  objDoc;       private void WordToolStripMenuItem_Click(object sender, EventArgs e)        {            string strsql = "Select * from TblSales where SalesID = " + txtSalesID            objWord = new Microsoft.Office.Interop.Word.Words();  <--- Error            objDoc = new Microsoft.Office.Interop.Word.Document();        }   }}

 
Please help me. Thank You.
Cheers,
Lennie

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi suthish nair
    Thank you for the URL address. Apparently the articles is referring to C#NET2003 and not C#NET2008. I did follow the instruction to  use WORD Object on my C#NET2008 and it created   error messages because C#NET2008 does not have this command:
     
    Error message
    Error 2 No overload for method 'AddOLEObject' takes '9' arguments 
     // Insert a chart

     Word.InlineShape objShape;

     object objclassType = "MSGraph.Chart.8";

     objTblRange = objDoc.Bookmarks.get_Item(ref objEndOfDoc).Range;

     

     objShape = objTblRange.InlineShapes.AddOLEObject(ref objclassType, ref  objMissing,refobjMissing, ref objMissing, ref objMissing,           

     ref objMissing, ref objMissing, ref objMissing, ref objMissing );

    --------------------------------------------------------------------------
    Error 3    The name 'BindingFlags' does not exist in the current context   

     //demonstrate use of Late bound chart and oChartAoo objects to

     //manipulate the chart object with MSGraph.

     object objChart;

     object objChartApp;

     objChart = objShape.OLEFormat.Object;

     objChartApp = objChart.GetType().InvokeMember("Application", BindingFlags.GetProperty,null, objChart, null);                                                                            

     

      //change the chart type to Line.

      object[] Parameters = new object[1];

      Parameters[0] = 4;      //xlLine = 4

      objChart.GetType().InvokeMember("ChartType",  BindFlags.SetsProperty, null, objChart, Parameters);

     

      //update the chart image and quit MSGraph.

      objChartApp.GetType().InvokeMember("Update", BindingFlags.InvokeMethod, null, objChartApp, null);

      objChartApp.GetType().InvokeMember("Quit", BindingFlags.InvokeMethod, null, objChartApp, null);

    0