PowerPoint VBA:如何将动画开始事件设置为 "With Previous"
PowerPoint VBA: How to set Animation Start event to "With Previous"
在 PowerPoint 宏中,我想将“动画”选项卡上 "Timing" 组中的 "Start" 设置为 "With Previous"。今天是我第一次用VBA,所以请不要笑我的代码:
子adjustAll()
显示为幻灯片
将 oshp 调暗为形状
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在哪里,对于另一个对象,我想将相同的东西设置为"On Click",并设置"Appear" 在 "Animation" 组中,"As One Object" 用于 "Effect Options"。
更新:这非常接近工作:
子adjustAll()
显示为幻灯片
将 oshp 调暗为形状
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
顺便说一句,如果您只检查媒体类型的占位符,您将错过内容占位符中插入的任何视频。
在 PowerPoint 宏中,我想将“动画”选项卡上 "Timing" 组中的 "Start" 设置为 "With Previous"。今天是我第一次用VBA,所以请不要笑我的代码:
子adjustAll() 显示为幻灯片 将 oshp 调暗为形状
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在哪里,对于另一个对象,我想将相同的东西设置为"On Click",并设置"Appear" 在 "Animation" 组中,"As One Object" 用于 "Effect Options"。
更新:这非常接近工作:
子adjustAll() 显示为幻灯片 将 oshp 调暗为形状
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
顺便说一句,如果您只检查媒体类型的占位符,您将错过内容占位符中插入的任何视频。