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