PC Review


Reply
Thread Tools Rate Thread

Can I get a chart object (excel.ChartObject) from OLE_chart.object

 
 
chris
Guest
Posts: n/a
 
      12th Dec 2008
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!
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      12th Dec 2008
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" <(E-Mail Removed)> wrote in message
news:195C1A5E-4163-4428-93FA-(E-Mail Removed)...
>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!



 
Reply With Quote
 
chris
Guest
Posts: n/a
 
      15th Dec 2008
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).


 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      15th Dec 2008
> 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" <(E-Mail Removed)> wrote in message
news:79F0E2EB-8C75-462F-BB22-(E-Mail Removed)...
> 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).
>
>



 
Reply With Quote
 
chris
Guest
Posts: n/a
 
      16th Dec 2008
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart Object and Worksheet Object win Microsoft Powerpoint 0 16th Dec 2009 02:28 AM
Method 'Height' of object 'ChartObject' failed Anand Nichkaode Microsoft Excel Programming 1 20th Nov 2008 11:08 AM
Using Microsoft Excel Chart object in VB6 fizbim Microsoft Excel Charting 0 13th Jul 2005 05:14 PM
How to Save Excel chart object as a GIF ? hype Microsoft Dot NET Framework 2 17th Jan 2005 02:10 PM
How to Safe Excel chart object as a GIF ? hype Microsoft Dot NET 0 30th Oct 2003 04:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:23 PM.