我試圖改變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