Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
COMException on InvokeMember
Hi,
I create an Excel chart in a Word document. I'm trying to change the chart type at runtime (using late binding): // Create the Word application and declare a document Word2007.Application word = new Word2007.Application(); Word2007.Document doc = new Word2007.Document(); // Define an object to pass to the API for missing parameters object missing = Type.Missing; object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ word.Visible = true; // Everything that goes to the interop must be an object object fileName = ", Path.GetDirectoryName(Application.ExecutablePath)) ; // Open the Word document. object varFalse = false; object varTrue = true; ; // Create a new file based on our template doc = word.Documents.Open(ref fileName, ref missing, ref varFalse, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref varTrue, ref missing, ref missing, ref missing, ref missing); //Insert a chart. object oClassType = "Excel.Chart.8"; Word2007.Range wrdRng = doc.Bookmarks.get_Item(ref oEndOfDoc).Range; InlineShape oShape = wrdRng.InlineShapes.AddOLEObject(ref oClassType, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); object oChart = oShape.OLEFormat.Object; object oChartApp = oChart.GetType().InvokeMember("Application", BindingFlags.GetProperty, null, oChart, null); //Change the chart type to Line. object[] Parameters = new Object[1]; Parameters[0] = 4; //xlLine = 4 oChart.GetType().InvokeMember("ChartType", BindingFlags.SetProperty, null, oChart, Parameters); Here (on InvorkeMember) I get a COMException ("Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))") My guess is that there is something wrong with the "ChartType" parameter... I use Office 2007, but mu code should also work with Office 2003 Can anyone help me please? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
COMException on InvokeMember
Found the problem:
I have installed an English Excel, but my regional settings are set to another language... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
COMException 0x800A03EC Whn Calling CheckOut | Excel Programming | |||
COMException 0x800A03EC Whn Calling CheckOut | Excel Programming | |||
getting System.Runtime.InteropServices.COMException | Excel Programming | |||
Strange exception when calling Worksheet.GetOLEObjects using Invokemember!! | Excel Programming | |||
I get COMException while exporting chart on IIS 6.0. | Charts and Charting in Excel |