import picture into powerpoint

  • Thread starter Thread starter persh
  • Start date Start date
P

persh

I am trying to import pictures into a powerpoint slide
presentation using this code but i am getting an error:

************************************
Private Sub cmdPowerPoint_Click()
Dim xloop As Integer
On Error Resume Next
Set ppObj = GetObject(, "PowerPoint.Application")
Dim Pic As Shape
Dim Sld As Slide

If Err.Number Then
Set ppObj = CreateObject("PowerPoint.Application")
Err.Clear
End If

On Error GoTo err_cmdOLEPowerPoint

Set ppPres = ppObj.Presentations.Add
'Set ppPres = ppObj.Slides.Add

Debug.Print "before"

'Set oPic = ActiveWindow.Selection.SlideRange.Shapes
Set Sld = ActivePresentation.Slides.Add
(ActivePresentation.Slides.Count + 1, ppLayoutBlank)
Set Pic =
ActiveWindow.Selection.SlideRange.Shapes.AddPicture
(FileName:="c:\prx.jpg", _
LinkToFile:=msoTrue, _
SaveWithDocument:=msoTrue, _
Left:=1, _
Top:=1, _

Width:=275, _
Height:=45)
Debug.Print "after"
..Slides(1).Shapes(1).TextFrame.TextRange.Text
= "Testing1!!!"

ppPres.SlideShowSettings.Run

End Sub
 
To be honest up front, I'm guessing here, but don't you mean to use ppPres?
And I'm not sure about ActiveWindow, where is that defined? Was this code
taken from a PowerPoint scripting example? If it was, it won't work just
copying and pasting it into Access. You have to go through the Power Point
object model to access these objects.

Set ppPres = ppObj.Presentations.Add
....
Set Sld = ppPres.Slides.Add
(ppPres.Slides.Count + 1, ppLayoutBlank)
....
 
Back
Top