随机形状在 powerpoint 延迟后消失
Random shapes to disappear after a delay in powerpoint
我有很多方块,它们后面会隐藏图片。
我会在ppt中的很多幻灯片中重复这个过程,这就是为什么我希望它是随机的。
我是宏的新手,不太了解它们。
有没有办法让一个随机方块消失,然后2秒后,另一个随机方块消失,依此类推?直到我停止它或所有方块都消失。
提前致谢。
我从 google.
那里获得了这段代码,点击后方块会消失
Sub triggerMe()
Dim osld As Slide
Dim oshp As Shape
Dim oeff As Effect
On Error Resume Next
Set oshp = ActiveWindow.Selection.ShapeRange(1)
If Not oshp Is Nothing Then
Set osld = oshp.Parent
Set oeff = osld.TimeLine.InteractiveSequences.Add.AddEffect(oshp, msoAnimEffectFade, , msoAnimTriggerOnShapeClick)
With oeff
.Timing.TriggerShape = oshp
.Exit = True
End With
End If
结束子
这是幻灯片的屏幕截图:
这是pptlink
所以这段代码有效。比我想象的要复杂很多。
Sub Dala()
currentslide = ActiveWindow.Selection.SlideRange.SlideIndex
Dim slideShapes As shapes
Dim slideShape As Shape
Dim osld As Slide
Dim oshp As Shape
Dim oeff As Effect
'Get shapes for the slide
Set slideShapes = ActivePresentation.Slides(currentslide).shapes
Dim MyListOfNumbers(0 To 500) As Integer
MyListOfNumbers(0) = 0
Dim r As Variant
Dim x As Integer
Dim exist As Boolean
Dim i As Integer
For Each slideShape In slideShapes
x = Random(slideShapes.Count)
'So that it does not double animate the same square again
For Each r In MyListOfNumbers
If r = x Then
exist = True
End If
Next r
'Animates and add it to the array
If exist = False Then
MyListOfNumbers(i) = x
Set oshp = slideShapes(x)
Set osld = oshp.Parent
On Error Resume Next
Set oshp = oshp
If Not oshp Is Nothing Then
Set osld = oshp.Parent
Set oeff = osld.TimeLine.MainSequence.AddEffect(oshp, msoAnimEffectFade, , msoAnimTriggerAfterPrevious)
With oeff
.Timing.TriggerDelayTime = 1
.Exit = True
End With
End If
i = i + 1
End If
exist = False
Next slideShape
End Sub
Function Random(High As Integer) As Integer
'Generates a random number less than or equal to
'the value passed in High
Randomize
Random = Int((High * Rnd) + 1)
End Function
我有很多方块,它们后面会隐藏图片。
我会在ppt中的很多幻灯片中重复这个过程,这就是为什么我希望它是随机的。
我是宏的新手,不太了解它们。
有没有办法让一个随机方块消失,然后2秒后,另一个随机方块消失,依此类推?直到我停止它或所有方块都消失。
提前致谢。
我从 google.
那里获得了这段代码,点击后方块会消失Sub triggerMe()
Dim osld As Slide
Dim oshp As Shape
Dim oeff As Effect
On Error Resume Next
Set oshp = ActiveWindow.Selection.ShapeRange(1)
If Not oshp Is Nothing Then
Set osld = oshp.Parent
Set oeff = osld.TimeLine.InteractiveSequences.Add.AddEffect(oshp, msoAnimEffectFade, , msoAnimTriggerOnShapeClick)
With oeff
.Timing.TriggerShape = oshp
.Exit = True
End With
End If
结束子
这是幻灯片的屏幕截图:
这是pptlink
所以这段代码有效。比我想象的要复杂很多。
Sub Dala()
currentslide = ActiveWindow.Selection.SlideRange.SlideIndex
Dim slideShapes As shapes
Dim slideShape As Shape
Dim osld As Slide
Dim oshp As Shape
Dim oeff As Effect
'Get shapes for the slide
Set slideShapes = ActivePresentation.Slides(currentslide).shapes
Dim MyListOfNumbers(0 To 500) As Integer
MyListOfNumbers(0) = 0
Dim r As Variant
Dim x As Integer
Dim exist As Boolean
Dim i As Integer
For Each slideShape In slideShapes
x = Random(slideShapes.Count)
'So that it does not double animate the same square again
For Each r In MyListOfNumbers
If r = x Then
exist = True
End If
Next r
'Animates and add it to the array
If exist = False Then
MyListOfNumbers(i) = x
Set oshp = slideShapes(x)
Set osld = oshp.Parent
On Error Resume Next
Set oshp = oshp
If Not oshp Is Nothing Then
Set osld = oshp.Parent
Set oeff = osld.TimeLine.MainSequence.AddEffect(oshp, msoAnimEffectFade, , msoAnimTriggerAfterPrevious)
With oeff
.Timing.TriggerDelayTime = 1
.Exit = True
End With
End If
i = i + 1
End If
exist = False
Next slideShape
End Sub
Function Random(High As Integer) As Integer
'Generates a random number less than or equal to
'the value passed in High
Randomize
Random = Int((High * Rnd) + 1)
End Function