Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default 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
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
Method 'Height' of object 'ChartObject' failed Anand Nichkaode Excel Programming 1 November 20th 08 11:08 AM
Select chart object in Excel 2007 Luca Brasi Excel Programming 4 August 29th 07 02:55 PM
Using Microsoft Excel Chart object in VB6 fizbim Charts and Charting in Excel 0 July 13th 05 05:14 PM
Confusion about how the Window object fits into the Excel object model Josh Sale Excel Programming 11 April 15th 05 06:08 PM
Find and replace data in an Excel chart object Cawen Charts and Charting in Excel 2 March 31st 05 06:47 PM


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