PDA

View Full Version : VBA video insertion for powerpoint



galagator
03-18-2011, 12:02 AM
Hi guys,

just wondering what the code is to:
Start Automatically
Play Full Screen
Hide While Not Playing

on video files.. so far I have:

Set oSlide = objApp.ActivePresentation.Slides(oldCount + 3)

Set oShp = oSlide.Shapes.AddMediaObject2(jobFolder & "\" & vFile, True, False)

oShp.AnimationSettings.PlaySettings.HideWhileNotPlaying = True

oSlide.TimeLine.MainSequence.AddEffect oShp, msoAnimEffectMediaPlay


Cheers guys!

John Wilson
03-18-2011, 09:35 AM
i don't think there's any convenient command in vba for Full screen. maybe you could resize to match the slide?

Dim ovid As Shape
Dim osld As Slide
Set osld = ActiveWindow.View.Slide
Set ovid = osld.Shapes.AddMediaObject("C:\Users\Public\Videos\Sample Videos\Wildlife.wmv")
With osld.TimeLine.MainSequence.AddEffect(ovid, msoAnimEffectMediaPlay, , msoAnimTriggerWithPrevious)
.EffectInformation.PlaySettings.HideWhileNotPlaying = True
End With
ovid.LockAspectRatio = False
ovid.Width = ActivePresentation.PageSetup.SlideWidth
ovid.Height = ActivePresentation.PageSetup.SlideHeight

galagator
03-20-2011, 09:48 PM
Thanks for the excellent tips, shame about the fullscreen mode!

What about if I were to create an OLE windows media player instance? Are the properties easy to set in that via VBA? I had temporarily abandoned the idea of a WMP control when I had to type the complete path to the video, but I have read you can use relative paths - not that it worked for me! :eek:

One other quick question, is it possible to set the background color of a slide to black quickly through VBA?

Thanks a lot for your help :bow:

John Wilson
03-21-2011, 12:46 AM
See if this helps:

Sub Add_player()
Dim osld As Slide
Dim oplayer As Shape
Set osld = ActivePresentation.Slides(1)
Set oplayer = osld.Shapes.AddOLEObject( _
Left:=10, _
Top:=10, _
Width:=240, _
Height:=160, _
ClassName:="WMPlayer.OCX.7")
With oplayer.OLEFormat.Object
.URL = "C:\Users\Public\Videos\Sample Videos\Wildlife.wmv"
.fullScreen = True
.windowlessVideo = True
End With
End Sub

Sub backcol()
Dim osld As Slide
Set osld = ActivePresentation.Slides(1)
With osld
.FollowMasterBackground = False
.Background.Fill.Solid
.Background.Fill.ForeColor.RGB = RGB(0, 0, 0)
End With
End Sub