Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I get a chart object (excel.ChartObject) from OLE_chart.object
I have procedures in VB6 for adding charts on excel worksheets. I use
variable EXL_CHRT (As excel.ChartObject) for setting source data etc. Now I created an OLE object on a form for chart preview before it is created. I can access it's worksheet with "OLE_chart.object.Worksheets(1)" for using my existing procedures for adding charts on worksheets. Can I get a chart object (As excel.ChartObject) from OLE_chart.object.Charts(1) in order to use existing procedures for setting chart settings ? ex. dim EXL_CHRT As excel.ChartObject SET EXL_CHRT = OLE_chart.object.Charts(1) EXL_CHRT.SetSourceData........ Thanks in advance! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I get a chart object (excel.ChartObject) from OLE_chart.object
I have no idea what you are after but the code snippets are not right at all
dim EXL_CHRT As excel.ChartObject SET EXL_CHRT = OLE_chart.object.Charts(1) instead Set EXL_CHRT = xlSheet.ChartObjects(1) ' or .ChartObjects("some-name") where xlSheet refers to the sheet containing the chartobject You may then want to refer to EXL_CHRT.Object.Some-method-or-property FYI, "Charts" refers to the collection chart-sheets in the workbook, if any. A Chart-sheet can contain chartobjects though that's not typical. If the above does not clarify describe what you have and what you want to do. Regards, Peter T "chris" wrote in message ... I have procedures in VB6 for adding charts on excel worksheets. I use variable EXL_CHRT (As excel.ChartObject) for setting source data etc. Now I created an OLE object on a form for chart preview before it is created. I can access it's worksheet with "OLE_chart.object.Worksheets(1)" for using my existing procedures for adding charts on worksheets. Can I get a chart object (As excel.ChartObject) from OLE_chart.object.Charts(1) in order to use existing procedures for setting chart settings ? ex. dim EXL_CHRT As excel.ChartObject SET EXL_CHRT = OLE_chart.object.Charts(1) EXL_CHRT.SetSourceData........ Thanks in advance! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I get a chart object (excel.ChartObject) from OLE_chart.ob
Thanks Peter for your message.
My existing procedures use (dim EXL_CHRT As excel.ChartObject) for setting chart's properties. Now I created an OLE object (Excel Chart). (Dim EXL_OLE_chrt As Excel.Chart - Set EXL_OLE_chrt = ole_excel_chart.object.Charts(1)). I was wondering whether I can access same object from both (EXL_CHRT & EXL_OLE_chrt) so I can pass them as parameter to procedure for setting chart properties instead of having 2 procedures, one for each type (ChartObject or Chart). |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I get a chart object (excel.ChartObject) from OLE_chart.ob
Set EXL_OLE_chrt = ole_excel_chart.object.Charts(1)).
You say you created a chart with the above but that cannot work in Excel, as I tried to explain before that syntax is incorrect. Assuming you are working with an embedded chart on a sheet Dim xlChtObj as Excel.Chart Dim xlCht as Excel.Chart ' assumes an embedded chart exists on the sheet Set xlChtObj = xlSheet.ChartObjects(1) Set xlCht = xlChtObj.Object.Chart call foo(xlChtObj.Object) or call foo(xlCht) Function foo(cht as Excel.Chart) 'do stuff End Function Note the object property of the "ChartObject" is the "Chart" (ChartObject might have been better named as say "ChartHolder"). If you are working with a chart sheet, the entire sheet is a "Chart" object, you can also have embedded ChartObjects on a Chart sheet. Regards, Peter T "chris" wrote in message ... Thanks Peter for your message. My existing procedures use (dim EXL_CHRT As excel.ChartObject) for setting chart's properties. Now I created an OLE object (Excel Chart). (Dim EXL_OLE_chrt As Excel.Chart - Set EXL_OLE_chrt = ole_excel_chart.object.Charts(1)). I was wondering whether I can access same object from both (EXL_CHRT & EXL_OLE_chrt) so I can pass them as parameter to procedure for setting chart properties instead of having 2 procedures, one for each type (ChartObject or Chart). |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I get a chart object (excel.ChartObject) from OLE_chart.ob
Thanks Peter.
I use the commands below for accessing a chart in OLE object. Dim exl_chrt As Excel.Chart Set exl_chrt = ole_excel_chart.object.Charts(1) My existing procedures had a parameter to CHARTOBJECT instead of CHART. That's why I was trying to retrieve the CHARTOBJECT from the 2 types of charts I was creating. I changed parameter to be CHART and retrieve chart object for both charts and it works. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Method 'Height' of object 'ChartObject' failed | Excel Programming | |||
Select chart object in Excel 2007 | Excel Programming | |||
Using Microsoft Excel Chart object in VB6 | Charts and Charting in Excel | |||
Confusion about how the Window object fits into the Excel object model | Excel Programming | |||
Find and replace data in an Excel chart object | Charts and Charting in Excel |