candphys
03-30-2015, 08:40 AM
Hi all,
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
Set sld = ActivePresentation.Slides.Add(ActivePresentation.Slides.count + 1, ppLayoutTitleOnly)
sld.Select
sld.Shapes.Title.TextFrame.TextRange.text = "CFD-Results: " & folder
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 + some complaint about video codecs
"
if I use it with larger videos or alternatively increase the number of videos on each slide or the number of slides containing 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 tell me that it's either some bug in ppt or may point to some sort of solution. Maybe I can configure ppt to accept more/bigger videos?
Many thanks.
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
Set sld = ActivePresentation.Slides.Add(ActivePresentation.Slides.count + 1, ppLayoutTitleOnly)
sld.Select
sld.Shapes.Title.TextFrame.TextRange.text = "CFD-Results: " & folder
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 + some complaint about video codecs
"
if I use it with larger videos or alternatively increase the number of videos on each slide or the number of slides containing 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 tell me that it's either some bug in ppt or may point to some sort of solution. Maybe I can configure ppt to accept more/bigger videos?
Many thanks.