Hello everybody,
I'm trying to run a simple Word macro that creates a new PowerPoint presentation and simply adds a picture to the presentation from a predefined path. The code works more or less because the presentation file is opened correctly and the picture is added to the newly created slide but somehow I always get a runtime error '13' Type mismatch.
If I write a macro that is used in a PowerPoint File to ad a picture to an existing presentation it works fine.
Here is the code for the macro I use in Word:
Option Explicit Sub TestMakro() ' ' TestMakro Macro ' ' Dim oSld As Slide Dim oPic As Shape Dim testInlineShape As InlineShape Dim pptApp As PowerPoint.Application Dim pptPres As PowerPoint.Presentation Set pptApp = CreateObject("PowerPoint.Application") Set pptPres = pptApp.Presentations.Add(msoTrue) Set oSld = pptPres.Slides.Add(pptPres.Slides.Count + 1, ppLayoutBlank) Set oPic = oSld.Shapes.AddPicture("C:\Temp\data_files\image001.png", msoFalse, msoTrue, 100, 100) End Sub
Thanks for your help.
Jan