Access to Powerpoint

PaulSpell

Registered User.
Local time
Today, 18:53
Joined
Apr 19, 2002
Messages
201
Does anyone have some code that will generate a chart in Powerpoint from data in an Access table?
 
Richary, thanks for your post.

I did eventually find this yesterday but the code is set up to overwrite the graph on slide 1 each time. Do you know what modifications would be necessary to create a new slide with each function call?
 
If you replace if CGFF_SavedPPT = "" Then ... Else .. End if with

If CGFF_SavedPPT = "" Then

' Use these lines to create a new Graph object on the slide.
Set OpwrPresent = OPwrPnt.Presentations.Add.Slides.Add(1, 12)
lheight = OPwrPnt.ActivePresentation.PageSetup.SlideHeight / 2
lwidth = OPwrPnt.ActivePresentation.PageSetup.SlideWidth / 2
LLeft = OPwrPnt.ActivePresentation.PageSetup.SlideHeight / 4
lTop = OPwrPnt.ActivePresentation.PageSetup.SlideHeight / 4
Set shpGraph = OpwrPresent.Shapes.AddOLEObject(Left:=LLeft, _
Top:=lTop, Width:=lwidth, Height:=lheight, _
ClassName:="MSGraph.Chart", Link:=0).OLEFormat.Object
FndGraph = True
Else

' Use these lines if you already have a saved chart
' on a PowerPoint
' slide.
Set OpwrPresent = _
OPwrPnt.Presentations.Open(CGFF_SavedPPT, False).Slides.Add(1, 12)
lheight = OPwrPnt.ActivePresentation.PageSetup.SlideHeight / 2
lwidth = OPwrPnt.ActivePresentation.PageSetup.SlideWidth / 2
LLeft = OPwrPnt.ActivePresentation.PageSetup.SlideHeight / 4
lTop = OPwrPnt.ActivePresentation.PageSetup.SlideHeight / 4
Set shpGraph = OpwrPresent.Shapes.AddOLEObject(Left:=LLeft, _
Top:=lTop, Width:=lwidth, Height:=lheight, _
ClassName:="MSGraph.Chart", Link:=0).OLEFormat.Object
FndGraph = True
End if


You will add a silde to the start of the presentation. Just remeber to call the function with the same name for CGF_PPTFilename as CGFF_SavedPPT for subsequent calls to the function

eg
CreateGraphFromFile("c:\MyPPT.ppt", "My recordset","")
CreateGraphFromFile("c:\MyPPT.ppt", "My second recordset","c:\MyPPT.ppt")

If you want to append (rather than preprend) slides, I belvie that you will need to get the slide count of OpwrPresent (after opening it) with OpwrPresent.Count and do something like

opwrpresent.add(OpwrPresent.Count+1,12)

Let me know if that last little bit isn't clear

Regs
Richard
 

Users who are viewing this thread

Back
Top Bottom