Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to find existing ChartObject in a worksheet?

My goal is to reuse the chartobject in a given sheet (ws).

int iCount = ws.ChartObjects.Count;
Excel.ChartObject myChartObject;

if( iCount 0)
{
myChartObject = (Excel.ChartObject)ws.ChartObjects(iCount);
}
else
{
Excel.ChartObjects chartObjects =
(Excel.ChartObjects)ws.ChartObjects(missing);
myChartObject = chartObjects.Add(100, 100, 400, 300);
}
....

But this code couldn't compile due to:

Microsoft.Office.Interop.Excel._Worksheet.ChartObj ects(object)' is a
'method', which is not valid in the given context

How could we detect if the existing ChartObject in a sheet? Could any
one help?

Thanks in advance for any hint.

--PD

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to find existing ChartObject in a worksheet?

On Feb 8, 9:22 am, "itdept" wrote:
My goal is to reuse the chartobject in a given sheet (ws).

int iCount = ws.ChartObjects.Count;
Excel.ChartObject myChartObject;

if( iCount 0)
{
myChartObject = (Excel.ChartObject)ws.ChartObjects(iCount);}

else
{
Excel.ChartObjects chartObjects =
(Excel.ChartObjects)ws.ChartObjects(missing);
myChartObject = chartObjects.Add(100, 100, 400, 300);}

...

But this code couldn't compile due to:

Microsoft.Office.Interop.Excel._Worksheet.ChartObj ects(object)' is a
'method', which is not valid in the given context

How could we detect if the existing ChartObject in a sheet? Could any
one help?

Thanks in advance for any hint.

--PD


Found solution:
Excel.ChartObjects chartObjects = (Excel.ChartObjects)
ws.ChartObjects(missing);
int iCount = chartObjects.Count;
Excel.ChartObject myChartObject;
if (iCount 0)
myChartObject = chartObjects(iCount);
else
myChartObject = chartObjects.Add(...)
...

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
Create Worksheet From Values in Existing Cells Using Existing Worksheet as Template. Ardy Excel Programming 18 November 29th 06 03:23 AM
Despite data existing in Excel 2002 spreadsheet Find doesn't find AnnieB Excel Discussion (Misc queries) 1 June 16th 06 02:15 AM
Find an existing file. கற்பகம் Excel Programming 2 September 29th 05 06:57 PM
Find existing worksheet Rob[_16_] Excel Programming 3 March 1st 04 04:58 AM
find existing worsheet monika Excel Programming 10 February 5th 04 02:03 PM


All times are GMT +1. The time now is 01:43 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"