vba - PowerPoint VBA : How to set Animation Start event to "With Previous"

标签 vba powerpoint

在 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

除了我最终得到两个触发器,这看起来不太正确,但似乎不会引起问题。

enter image description here

更新:希望最终更新。我想我只需要清除音频的默认动画。我将其添加到条件的顶部:

            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/

相关文章:

php - 在 apache 服务器上使用 PHP 将 ppt/pptx 转换为 JPG/PNG

excel - Powerpoint通过Excel VBA断开链接

excel - 如果我后来从其中任何一个中删除了任何超链接,为什么excel会删除所有粘贴的超链接?

vba - 如果满足条件,如何将行复制到新工作表中?

vba - Excel VBA - 将变量设置为公式的值

未检测到 Powerpoint 形状中的 C# 文本

VBA 加载项 : how to "embed" the required reference libraries? 向其他用户发送功能加载项时获取 "Compile error in hidden module"

regex - 使用 word VBA 正则表达式提取文本,然后将其作为字符串保存到变量中

vba - excel将数据而不是公式传递给其他工作表

powerpoint - 将Powerpoint查看器嵌入网页(PHP)