The code is nearly the same. The difference is that you have to qualify the
code in VB6 a bit more formally.
For instance, you need a variable pointing to the working instance of Excel.
Supposing the variable is xlApp, then the code I posted looks like this:
With xlApp.ActiveChart.SeriesCollection.NewSeries
.Name = ActiveSheet.Range("G3")
.Values = ActiveSheet.Range("G4:G14")
.XValues = ActiveSheet.Range("A4:A14")
End With
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______
> Jon,
>
[quoted text clipped - 56 lines]
>>>
>>> Michael
mb - 27 May 2008 14:05 GMT
Here's a snippet of my code:
OLE1.CreateEmbed "", "Excel.Chart.5"
Set objChart = OLE1.object.ActiveChart
Set objSheet = objChart.Parent.Worksheets(1)
Set objXL = objChart.Application
I tried substituting both "OLE1.object.Application" and "objXL" for xlApp in
your example:
With objXL.ActiveChart.SeriesCollection.NewSeries
.Name = ActiveSheet.Range("G3")
.Values = ActiveSheet.Range("G4:G14")
.XValues = ActiveSheet.Range("A4:A14")
End With
But I get the error: <Object variable or With block variable not set>
A watch on objXL shows it equal to "Microsoft Excel", but the ".ActiveChart"
provokes the error.
Any thoughts?
thanks,
Michael
>The code is nearly the same. The difference is that you have to qualify the
>code in VB6 a bit more formally.
[quoted text clipped - 75 lines]
>>>>
>>>> Michael
Jon Peltier - 27 May 2008 20:52 GMT
If your objChart is reliably defined, then:
With objChart.SeriesCollection.NewSeries
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______
> Here's a snippet of my code:
>
[quoted text clipped - 110 lines]
>>>>>
>>>>> Michael