LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel 2000 chart location problem

Hi!

I'm trying to create charts in Excel 2000 Professional (SP-3)
programmatically, using C# (Visual Studio .NET 2005), but there seems
to be a problem. When I set the location of a chart, it is always
placed on the first worksheet, no matter what parameter I specify as
the worksheet name.

For example, the following code:

Excel._Application applic = new Excel.Application();
if (applic == null)
{
Console.WriteLine("Error!");
return;
}

applic.Visible = true;

Workbooks workbooks = applic.Workbooks;
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
_Worksheet worksheet = (_Worksheet)workbook.Worksheets.get_Item(1);
worksheet.Name = "Worksheet1";
_Worksheet newWorksheet =
(_Worksheet)workbook.Worksheets.Add(Missing.Value,
(_Worksheet)workbook.Worksheets.get_Item(1), 1,
XlSheetType.xlWorksheet);
newWorksheet.Name = "Worksheet2";
Range oRange = worksheet.get_Range("B2", "E2");

_Chart oChart = (_Chart)workbook.Charts.Add(Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
oChart.ChartWizard(oRange, Missing.Value, Missing.Value,
XlRowCol.xlRows, Missing.Value, Missing.Value, Missing.Value, "My
chart", Missing.Value, Missing.Value, Missing.Value);

// here's the problem
oChart.Location(XlChartLocation.xlLocationAsObject , "Worksheet2"); //
instead of placing the chart on "Worksheet2", the chart appears on
"Worksheet1" !!!

Console.ReadLine(); // so that Excel doesn't close immediately
applic.Quit();


Could anyone please explain why the chart is not where it is supposed
to be?
And why does this happen only in Excel 2000? In Excel 2003 and Office
XP, the chart is placed correctly (on the second worksheet).

I have to place a chart on a worksheet different from the first one in
Excel 2000; please tell me how to do this in a different way (the above
code doesn't behave as expected).

 
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
EXcel 2000 pro auto backup location Tazzer Excel Discussion (Misc queries) 2 January 12th 09 06:08 PM
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] Excel Discussion (Misc queries) 2 September 10th 08 11:07 AM
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] New Users to Excel 2 September 10th 08 11:07 AM
Excel 2000 - How to find cell location of a link to another file? WINDMILL Excel Discussion (Misc queries) 2 July 12th 07 03:46 PM
Chart SeriesCollection. Problem changing from Excel 2000 to 2002 [email protected] Excel Programming 4 July 6th 04 08:15 AM


All times are GMT +1. The time now is 09:15 PM.

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

About Us

"It's about Microsoft Excel"