How to add pictures into PowerPoint using Access

fkneg1

Registered User.
Local time
Today, 12:25
Joined
Aug 11, 2013
Messages
23
Hello,
I am using access 2013 to make a PowerPoint presentation based on the data in a query. I know how to do that much using VBA but I am also trying to make a slide with a picture on it from a saved location. I have tried various things without any luck. This is my VBA code:

Dim db As Database, rs As Recordset
Dim ppObj As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation

On Error GoTo err_cmdOLEPowerPoint

' Open up a recordset on the table.
Set db = CurrentDb
Set rs = db.OpenRecordset("All chosen songs", dbOpenDynaset)


' Open up an instance of Powerpoint.
Set ppObj = New PowerPoint.Application
Set ppPres = ppObj.Presentations.Add

' Setup the set of slides and populate them with data from the
' set of records.
With ppPres
While Not rs.EOF
With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutLargeObject)
.Shapes.AddPicture(FileName:="D\Desktop\JDJ\ECC\PowerPoints\ECC logo.jpg").Select

End With

With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutTitle)
End With
rs.MoveNext
Wend
End With

' Run the show.
ppPres.SlideShowSettings.Run

Exit Sub

err_cmdOLEPowerPoint:
MsgBox Err.Number & " " & Err.Description
End Sub

At the moment I am not worrying about adding the data as I know how to do this and had it working before - its just adding the picture to the slide. Any help appreciated!
 
"no luck" conveys 0 debugging information.

Always
1. State what you want (check)
2. What do you do with what code (check)
3. What does the code do (errormessage? nothoing happens?output right/wrong)
4. If error - what error TEXT and what line failed

BTW: Having an On Error error handler active while trying to make code work is completely pointless, because it disguises location of any errors you may have committed. Disable the thing.
 

Users who are viewing this thread

Back
Top Bottom