Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Create Worksheet From Values in Existing Cells Using Existing Worksheet as Template. | Excel Programming | |||
Despite data existing in Excel 2002 spreadsheet Find doesn't find | Excel Discussion (Misc queries) | |||
Find an existing file. | Excel Programming | |||
Find existing worksheet | Excel Programming | |||
find existing worsheet | Excel Programming |