View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
KJD KJD is offline
external usenet poster
 
Posts: 2
Default Powerpoint charting from excel

Hi,

I have put my code below that I am attempting to open
PowerPoint and insert a new slide containing a chart -
however when I try to access the chart (lines highlighted
with a *** below) the program crashes - is there anyone
who can help me with the correct code please?

Many thanks in advance

KJD


Dim oPPTShape As PowerPoint.Shape
Dim rngNewRange As Excel.Range
Dim oGraph As Object
Dim lLastSlide As Long

' Change this to the auto layout you want to use. This
value can be
' any PpSlideLayout constant.
Const DEFAULT_AUTO_LAYOUT As Long = ppLayoutChart
' Get the number of slides in the active presentation.
lLastSlide = oPPTApp.ActivePresentation.Slides.Count
lLastSlide = lLastSlide + 1
oPPTApp.ActivePresentation.Slides.Add lLastSlide,
DEFAULT_AUTO_LAYOUT

With oPPTApp.ActivePresentation.Slides(lLastSlide)
With .Shapes(1)
With .TextFrame.TextRange
.Text = chart_title
.Font.Name = "Arial"
.Font.Size = 24
End With
End With
Set oPPTShape = oPPTApp.ActivePresentation.Slides
(lLastSlide).Shapes(2)
**** oPPTShape.OLEFormat.Activate
**** Set rngNewRange = Sheets("charts").Range
(chart_range)
**** Sheets("charts").Select
**** Range(chart_range).Select
**** rngNewRange.Copy
**** Set oGraph = .OLEFormat.Object
**** oGraph.Application.DataSheet.Range
("A0:Z100").Delete
**** oGraph.Application.DataSheet.Range
("A0").Paste False
**** oGraph.Application.Update
Set oPPTShape = Nothing
End With