我试图改变WMV视频到MP4在这个宏改变在PowerPoint西元:错误使用VBA
Sub mp4_to_wmv()
Dim src, ptrn, re, Match, Matches
ptr1 = "(\w+)"
Create the regular expression.
Set re = CreateObject("vbscript.regexp")
re.Pattern = ptr1
re.IgnoreCase = False
re.Global = True
For Each pptSlide In ActivePresentation.Slides
For Each pptShape In pptSlide.Shapes
'If it's a video
If pptShape.Type = msoMedia Then
Set Matches = re.Execute(pptShape.Name)
' If the video is mp4 then we create the wmv video
If Matches(1).Value = "mp4" Then
' We delete the mp4 video
pptShape.Delete
' We create the video
MyDocument = ActivePresentation.Path & "\" & Matches(0).Value & ".wmv"
' The insertion part is the part giving me trouble,
Set Test = pptShape(FileName:=myDocument, Left:=156, Top:=0, Width:=2048, Height:=922)
' Once we have the new video, we have to configure it to start automatically
Set oEffect = myDocument.TimeLine.MainSequence.AddEffect(myDocument.Shapes(3), msoAnimEffectMediaPlay, , msoAnimTriggerWithPrevious)
' I'm not sure this part works...
With Test.AnimationSettings.PlaySettings
.PlayOnEntry = True
.LoopUntilStopped = msoCTrue
End With
End If
End If
Next
Next
End Sub
我试图做的是插入该工作示例进入死循环,但我我不能够做正确
Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddMediaObject FileName:="C:\Windows\clock.avi",Left:=5, Top:=5, Width:=100, Height:=100
我想我必须在当前文件夹中两个视频WMV和MP4。 任何帮助,将不胜感激。
你得到了什么样的错误(数量和在哪一行)。你是否声明了'myDocument'变量(以哪种方式)? –
最后搞清楚了,我把AddMediaObject问题带入循环 – Angrod