nimmis
07-08-2008, 10:13 AM
I need to add objects to a PPT presentation:
I have this code to add pictures to PPT
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:\nimmi\sage\reports\MAS.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:nimmi\sage\reports\GeographicAnalysisByStateChart.jpg", _
msoFalse, msoTrue, 0, 0, 1, 1)
' Now scale the image
oPicture.ScaleHeight 1, msoTrue
oPicture.ScaleWidth 1, msoTrue
End With
End Function
I modified it to
Set oPicture = .AddOLEObject("K:nimmi\sage\reports\GeographicAnalysisByStateChart.snp", _
msoFalse, msoTrue, 0, 0, 1, 1)
Seemed simple enough. But now I am getting runtime error 13 type mismatch. Can someone please help???
I have this code to add pictures to PPT
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:\nimmi\sage\reports\MAS.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:nimmi\sage\reports\GeographicAnalysisByStateChart.jpg", _
msoFalse, msoTrue, 0, 0, 1, 1)
' Now scale the image
oPicture.ScaleHeight 1, msoTrue
oPicture.ScaleWidth 1, msoTrue
End With
End Function
I modified it to
Set oPicture = .AddOLEObject("K:nimmi\sage\reports\GeographicAnalysisByStateChart.snp", _
msoFalse, msoTrue, 0, 0, 1, 1)
Seemed simple enough. But now I am getting runtime error 13 type mismatch. Can someone please help???