Article ID: 172836
Article Last Modified on 10/11/2006
Sub ChangeChartType()
Dim oGraphShape As PowerPoint.Shape
Dim oGraph As Graph.Chart
' Set up an array to hold different chart types.
Dim lChartTypeArray(1 To 5) As Long
' Populate the array with different chart types.
lChartTypeArray(1) = xl3DPie
lChartTypeArray(2) = xl3DColumn
lChartTypeArray(3) = xlBubble3DEffect
lChartTypeArray(4) = xlPyramidBarStacked
lChartTypeArray(5) = xlSurfaceTopView
' Create a new presentation.
Dim oPres As PowerPoint.Presentation
Set oPres = PowerPoint.Presentations.Add
Dim x As Long
For x = 1 To 5
' Create a new slide.
oPres.Slides.Add x, ppLayoutBlank
With oPres.Slides(x)
' Create the Graph object.
Set oGraphShape = .Shapes _
.AddOLEObject(0,0,oPres.PageSetup.SlideWidth, _
oPres.PageSetup.SlideHeight, _
"MSGraph.Chart", _
Link:=msoFalse)
End With
' Get an object reference to the Graph you just created.
Set oGraph = oGraphShape.OLEFormat.Object
' Set the chart type.
oGraph.ChartType = lChartTypeArray(x)
' Release the reference.
Set oGraph = Nothing
Next x
End Sub
176476 OFF: Office Assistant Not Answering Visual Basic Questions
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: 8.00 ppt8 vba vbe macppt
Keywords: kbcode kbdtacode kbhowto kbmacro kbprogramming KB172836