Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COMException 0x800A03EC Whn Calling CheckOut Charles Chen Excel Programming 0 April 30th 08 03:23 AM
COMException 0x800A03EC Whn Calling CheckOut Charles Chen Excel Programming 0 April 30th 08 03:22 AM
getting System.Runtime.InteropServices.COMException Aruna Akella Excel Programming 0 August 7th 07 12:28 AM
Strange exception when calling Worksheet.GetOLEObjects using Invokemember!! Sarang Bapat Excel Programming 0 March 23rd 07 09:01 AM
I get COMException while exporting chart on IIS 6.0. asp newbie Charts and Charting in Excel 1 May 16th 06 08:27 AM


All times are GMT +1. The time now is 07:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"