import picture into powerpoint

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
 
B

Bryan Reich [MSFT]

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)
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top