Inserting graphs in powerpoint

Gannet

Registered User.
Local time
Today, 09:44
Joined
Sep 21, 2006
Messages
55
Code:
Dim ppapp As PowerPoint.Application
Dim prs As PowerPoint.Presentation
Dim wnd As PowerPoint.DocumentWindow
Dim strMilestones As String
Dim FilePath As String

FilePath = CurrentProject.Path

'create powerpoint object
    Set ppapp = CreateObject("Powerpoint.Application")
    ppapp.Visible = True
    'ppapp.WindowState = ppWindowMinimized

'open base.ppt as template
    Set prs = ppapp.Presentations.Open(FilePath & "\base.ppt")
    
'save as condition name
    prs.SaveAs FilePath & "\test.ppt"
    
    Set wnd = ppapp.ActiveWindow
    wnd.ViewType = ppViewSlide

'set title page
    wnd.View.GotoSlide Index:=1
    wnd.Selection.SlideRange.Shapes("Rectangle 2").Select
    wnd.Selection.TextRange.Text = "Graphs" & vbCrLf & Day(Now()) & "/" & Month(Now) & "/" & Year(Now)
    

'duplicate blank slide
    wnd.View.GotoSlide Index:=2
    wnd.Selection.SlideRange.Duplicate
    wnd.View.GotoSlide Index:=2


'add chart
  
     wnd.Selection.SlideRange.Shapes.AddOLEObject 100, 100, 500, 400, ClassName:="MSGraph.Chart"

I've used the above code I got from here for inserting a generic chart into powerpoint from a command button. I want to modify it to pull a chart(Graph1) from my form(frmGraphs) to insert into a new slide. Am I on the right track or will this not work?
 

Users who are viewing this thread

Back
Top Bottom