Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default I can't believe how complicated this is...

Continued from my previous question on Charting...

I now have this code, it will get to the second series and then it dies with
this error.

System.InvalidCastException was unhandled
OleAut reported a type mismatch.
....on this line...
mySeries[1] =
mySeriesCollection.Add((Excel.Range)myWorksheet.ge t_Range("D2", "D13"),
Excel.XlRowCol.xlColumns, false, false, false);

I'm not seeing where the Casting issue is here. After all it, completes the
series line on the chart, then gets the exception.

Here is the method in full:

mySeries = new Microsoft.Office.Interop.Excel.Series[4];
myChart = myWorkbook.Charts.Add(missing, missing, missing,
missing) as Excel.Chart;
myExcelApp.ActiveChart.ChartType =
Excel.XlChartType.xlXYScatterSmooth;
myExcelApp.ActiveChart.Name = "Time Analysis Chart";
myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(1) ;
myExcelApp.ActiveChart.SetSourceData(myWorksheet.g et_Range("D2",
"D13"),
Excel.XlRowCol.xlColumns);

mySeriesCollection =
(Excel.SeriesCollection)myChart.SeriesCollection(m issing);
mySeries[0] = mySeriesCollection.Item(mySeriesCollection.Count);
mySeries[0].Name = "5442";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(2) ;
mySeries[1] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[1].Name = "5441";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(3) ;
mySeries[2] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[2].Name = "5440";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(4) ;
mySeries[3] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[3].Name = "5439";

Thanks, in advance:)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default I can't believe how complicated this is...

I am sorry I did not formulate my question right. In my example I have only
one range (a8:a30). I need it, after it matches the cell = 1122 in column
A, to go to column B and meet another condition. Basically, I need it to
match column A with column B and then I want it to evaluate IF.
--
Sergei D


"ChartsToBe" wrote:

Continued from my previous question on Charting...

I now have this code, it will get to the second series and then it dies with
this error.

System.InvalidCastException was unhandled
OleAut reported a type mismatch.
...on this line...
mySeries[1] =
mySeriesCollection.Add((Excel.Range)myWorksheet.ge t_Range("D2", "D13"),
Excel.XlRowCol.xlColumns, false, false, false);

I'm not seeing where the Casting issue is here. After all it, completes the
series line on the chart, then gets the exception.

Here is the method in full:

mySeries = new Microsoft.Office.Interop.Excel.Series[4];
myChart = myWorkbook.Charts.Add(missing, missing, missing,
missing) as Excel.Chart;
myExcelApp.ActiveChart.ChartType =
Excel.XlChartType.xlXYScatterSmooth;
myExcelApp.ActiveChart.Name = "Time Analysis Chart";
myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(1) ;
myExcelApp.ActiveChart.SetSourceData(myWorksheet.g et_Range("D2",
"D13"),
Excel.XlRowCol.xlColumns);

mySeriesCollection =
(Excel.SeriesCollection)myChart.SeriesCollection(m issing);
mySeries[0] = mySeriesCollection.Item(mySeriesCollection.Count);
mySeries[0].Name = "5442";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(2) ;
mySeries[1] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[1].Name = "5441";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(3) ;
mySeries[2] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[2].Name = "5440";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(4) ;
mySeries[3] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[3].Name = "5439";

Thanks, in advance:)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default I can't believe how complicated this is...

I think you submitted that reply to the wrong thread:|

"Sergei D" wrote:

I am sorry I did not formulate my question right. In my example I have only
one range (a8:a30). I need it, after it matches the cell = 1122 in column
A, to go to column B and meet another condition. Basically, I need it to
match column A with column B and then I want it to evaluate IF.
--
Sergei D


"ChartsToBe" wrote:

Continued from my previous question on Charting...

I now have this code, it will get to the second series and then it dies with
this error.

System.InvalidCastException was unhandled
OleAut reported a type mismatch.
...on this line...
mySeries[1] =
mySeriesCollection.Add((Excel.Range)myWorksheet.ge t_Range("D2", "D13"),
Excel.XlRowCol.xlColumns, false, false, false);

I'm not seeing where the Casting issue is here. After all it, completes the
series line on the chart, then gets the exception.

Here is the method in full:

mySeries = new Microsoft.Office.Interop.Excel.Series[4];
myChart = myWorkbook.Charts.Add(missing, missing, missing,
missing) as Excel.Chart;
myExcelApp.ActiveChart.ChartType =
Excel.XlChartType.xlXYScatterSmooth;
myExcelApp.ActiveChart.Name = "Time Analysis Chart";
myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(1) ;
myExcelApp.ActiveChart.SetSourceData(myWorksheet.g et_Range("D2",
"D13"),
Excel.XlRowCol.xlColumns);

mySeriesCollection =
(Excel.SeriesCollection)myChart.SeriesCollection(m issing);
mySeries[0] = mySeriesCollection.Item(mySeriesCollection.Count);
mySeries[0].Name = "5442";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(2) ;
mySeries[1] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[1].Name = "5441";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(3) ;
mySeries[2] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[2].Name = "5440";

myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(4) ;
mySeries[3] = mySeriesCollection.Add(myWorksheet.get_Range("D2",
"D13"), Excel.XlRowCol.xlColumns, false, false, false);
mySeries[3].Name = "5439";

Thanks, in advance:)

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
Complicated Look-Up Greg Excel Discussion (Misc queries) 1 January 19th 10 05:05 PM
a little complicated Gaurav[_2_] Excel Worksheet Functions 7 March 18th 08 12:12 AM
This is more complicated than it looks. dollarbill79 Excel Worksheet Functions 11 July 13th 06 11:33 PM
Complicated Brett Excel Worksheet Functions 3 January 6th 06 03:29 PM
Complicated One! Mary[_6_] Excel Programming 3 February 25th 05 07:38 PM


All times are GMT +1. The time now is 10:52 PM.

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"