在 PowerPoint 宏中,我想将“动画”选项卡上“计时”组中的“开始”设置为“与上一个一起”。今天是我第一次使用 VBA,所以请不要 mock 我的代码:
子调整All() 变暗 osld 作为幻灯片 调暗 ohp 作为形状
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoMedia Then
If oshp.MediaType = ppMediaTypeSound Then
oshp.Left = 460.7499
oshp.Top = 250.7499
oshp.AnimationSettings.PlaySettings.LoopUntilStopped = True
End If
End If
Next oshp
Next osld
End Sub
也许我需要使用 AddEffect(),但这似乎有点过于复杂?我看过一些文档和帖子,但没有找到要设置的属性或要应用的值。
我并不是想问多个问题,但如果有人可以进一步提供帮助或告诉我在哪里 RTFM,对于另一个对象,我想将相同的内容设置为“单击时”,并设置“出现”在“动画”组和“效果选项”的“作为一个对象”中。
更新:这非常接近工作:
子调整All() 变暗 osld 作为幻灯片 调暗 ohp 作为形状
For Each osld In ActivePresentation.Slides
For i = osld.TimeLine.MainSequence.Count To 1 Step -1
osld.TimeLine.MainSequence(i).Delete
Next i
For Each oshp In osld.Shapes
If oshp.Type = msoPlaceholder Then
If oshp.Name <> "Content Placeholder 2" Then
oshp.AnimationSettings.Animate = False
End If
If oshp.Name = "Content Placeholder 2" Then
Set oeff = osld.TimeLine.MainSequence.AddEffect(Shape:=oshp, effectid:=msoAnimEffectAppear, trigger:=msoAnimTriggerOnPageClick)
oshp.AnimationSettings.AnimationOrder = 1
End If
End If
If oshp.Type = msoMedia Then
If oshp.MediaType = ppMediaTypeSound Then
Set oeff = osld.TimeLine.MainSequence.AddEffect(Shape:=oshp, effectid:=msoAnimEffectMediaPlay, trigger:=msoAnimTriggerWithPrevious)
oshp.Left = 460.7499
oshp.Top = 250.7499
oshp.ScaleHeight 0.2, msoTrue
oshp.ScaleWidth 0.2, msoTrue
oshp.AnimationSettings.PlaySettings.LoopUntilStopped = True
End If
End If
Next oshp
Next osld
End Sub
除了我最终得到两个触发器,这看起来不太正确,但似乎不会引起问题。
更新:希望最终更新。我想我只需要清除音频的默认动画。我将其添加到条件的顶部:
If oshp.MediaType = ppMediaTypeSound Then
oshp.AnimationSettings.Animate = False
最佳答案
PowerPoint 编程有点过于复杂。 AddEffect 正是您需要使用的:
Sub AdjustTable()
Dim oSlide As Slide
Dim oShape As Shape
Dim oEffect As Effect
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSld.Shapes
If oShape.Type = msoMedia Then
If oShape.MediaType = ppMediaTypeSound Then
oShape.Left = 460.7499
oShape.Top = 250.7499
Set oEffect = oSlide.TimeLine.MainSequence.AddEffect(Shape:=oShape, _
effectid:=msoAnimEffectMediaPlay, MsoAnimateByLevel:=msoAnimateLevelNone, _
MsoAnimTriggerType:=msoAnimTriggerWithPrevious)
End If
End If
Next oShape
Next oSlide
End Sub
顺便说一句,如果您只检查媒体类型的占位符,您将错过插入内容占位符中的任何视频。
关于vba - PowerPoint VBA : How to set Animation Start event to "With Previous",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59131485/