Reputation: 1
I was wondering, if there is a maximum number of videos in ppt that one can import via "AddMediaObject2" in VBA? I get a strange error, if I try to import several videos with the following macro (which is a dummy version just to show the problem) :
Sub loadVideos()
Const path As String = "D:\video.avi"
For folder = 1 To 20
Debug.Print "folder: " & folder
Dim sld As Slide
Set sld = ActivePresentation.Slides.Add(ActivePresentation.Slides.count + 1, ppLayoutTitleOnly)
sld.Select
For i = 1 To 8
Dim oShp As Shape
Set oShp = sld.Shapes.AddMediaObject2(FileName:=(path), _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, _
Top:=0, _
Width:=-1, _
Height:=-1)
Next i
Next folder
End Sub
It works as expected with smaller video files (so code should be alright!?) but I get the error
"Runtime error -214.... Shapes.AddMediaObject2 : Invalid request, PowerPoint cannot insert any video from the chosen file. Check whether the necessary codec for this media format is installed and repeat the procedure. "
if I use it with larger videos or alternatively increase the number of videos on each slide or the number of slides containing videos. I doubt that it has something to do with video codecs, because inserting the videos manually works fine and also the videos inserted so far (till the error occurs) work fine. I also checked that RAM is not completely filled by all these inserted videos. So I suppose there may be some internal stack or cache memory problem in ppt. Is there any restriction to the number or size of media files that can be loaded in ppt?
I would be very grateful, if someone could either tell me that it may be some bug in ppt or may point to some sort of remedy. Maybe I can configure ppt to accept more/bigger videos?
Many thanks.
Upvotes: 0
Views: 195
Reputation: 1
Same story for me i could only add 8 mpg files (regardles of installed codecs). Solution is to open and close presentation after adding single file (sample code above)
ps After converting mpg to avi method works fine...
For Each myBrand In Brands
Set ReturnPPPresentation = PptApp.Presentations.Open(tmpPresenationPath, withwindow:=msoFalse)
Set mySlajd = PPTTemplate.Slides(2).Duplicate
With mySlajd
Set shp = .Shapes.AddMediaObject2(myBrand.MultimediaPath, msoFalse, msoTrue, 218, 118.22, 384.71, 211.77)
Set shp = Nothing
End With
ReturnPPPresentation.Save
ReturnPPPresentation.Close
Next myBrand
Upvotes: 0