vba to insert objets to ppt

I have a bunch of snapshot files that need to added to PPT.

This function below adds pictures to PPT, I need to change it to add OLEObjects.

So, I modified this from

Set oPicture = .AddPicture("K:nimmisage
eportsGeographicAnalysisByStateChart.snp", _
msoFalse, msoTrue, 0, 0, 1, 1)
to
Set oPicture = .AddOLEObject("K:nimmisage
eportsGeographicAnalysisByStateChart.snp", _
msoFalse, msoTrue, 0, 0, 1, 1)

Now I get runtime error 13 Type mismatch. Can someone out there help me?

Thanks


Function InsertObjectOnSlide()

Dim oPPTApp As PowerPoint.Application
Dim oPPTPres As PowerPoint.Presentation
Dim oPPTShape As PowerPoint.Shape
Dim oPPTCurrentSlide As PowerPoint.Slide
Dim sPresentationFile As String

sPresentationFile = "K:
immisage
eportsMAS.PPT"

Set oPPTApp = New PowerPoint.Application
oPPTApp.Visible = True
oPPTApp.WindowState = ppWindowMinimized

Set oPPTPres = oPPTApp.Presentations.Open(sPresentationFile)
Set oPPTCurrentSlide = oPPTPres.Slides.Add(Index:=1, _
Layout:=ppLayoutBlank)


With oPPTCurrentSlide.Shapes
' Adds a picture to slide 1 in the active presentation.
Set oPicture = .AddPicture("K:nimmisage
eportsGeographicAnalysisByStateChart.snp", _
msoFalse, msoTrue, 0, 0, 1, 1)
' Now scale the image
oPicture.ScaleHeight 1, msoTrue
oPicture.ScaleWidth 1, msoTrue

End With
End Function
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories