Programmatically change the axis number format in an excel chart i

G

Guest

gI am adding an excel chart into a presenation and setting the datasheet
values via VB. This is working fine. How do I expose the properties for
changin the axis font, number format, etc. within the chart object. I also
need to change the color for the series bar based on the value for the row.

I changed the object type from "MSGraph.Chart" to "Excel.Chart" and now I
am getting an error on the list line of this code.

Set oShape = oSlide.Shapes.AddOLEObject(iLeft, iTop, iHeight,
iWidth, "Excel.Chart.8")
Set oOLEFormat = oShape.OLEFormat
Set oChart = oOLEFormat.Object

I changes the OLEObject type to try to get to the properties that I did not
see in the MSGraph object.

Anyone have any ideas on where these properties are hiding in the object?

Thanks
 
H

hu zhenghui

gI am adding an excel chart into a presenation and setting the datasheet
values via VB. This is working fine. How do I expose the properties for
changin the axis font, number format, etc. within the chart object. I also
need to change the color for the series bar based on the value for the row.

I changed the object type from "MSGraph.Chart" to "Excel.Chart" and now I
am getting an error on the list line of this code.

Set oShape = oSlide.Shapes.AddOLEObject(iLeft, iTop, iHeight,
iWidth, "Excel.Chart.8")
Set oOLEFormat = oShape.OLEFormat
Set oChart = oOLEFormat.Object

I changes the OLEObject type to try to get to the properties that I did not
see in the MSGraph object.

Anyone have any ideas on where these properties are hiding in the object?

Thanks

Try to do this by VBA for excel first.
 
S

Steve Rindsberg

gI am adding an excel chart into a presenation and setting the datasheet
values via VB. This is working fine. How do I expose the properties for
changin the axis font, number format, etc. within the chart object. I also
need to change the color for the series bar based on the value for the row.

I changed the object type from "MSGraph.Chart" to "Excel.Chart" and now I
am getting an error on the list line of this code.

Set oShape = oSlide.Shapes.AddOLEObject(iLeft, iTop, iHeight,
iWidth, "Excel.Chart.8")
Set oOLEFormat = oShape.OLEFormat
Set oChart = oOLEFormat.Object

I changes the OLEObject type to try to get to the properties that I did not
see in the MSGraph object.

Anyone have any ideas on where these properties are hiding in the object?

You don't show the DIM statements for your variables; I'm guessing that they're
the wrong type.

Add a reference to Excel then try this:

Sub BetterNowMaybe()

Dim oShape As Shape
Dim oChart As Excel.Chart
Dim oSlide As Slide

Set oSlide = ActivePresentation.Slides(1)
Set oShape = oSlide.Shapes.AddOLEObject(0, 0, 700, 500, "Excel.Chart.8")
Set oChart = oShape.OLEFormat.Object.Charts(1)
With oChart
.ChartArea.Fill.ForeColor.SchemeColor = 42
End With
End Sub

And inside the With/End With block, Intellisense will show you the chart
properties you're after.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top