2013-03-18 24 views
0

我試圖在PowerPoint中編寫一個基本上是IF語句的宏。我有4盒,我有動畫,當他們點擊時,他們淡出。是否有可能擁有一個宏,可以識別所有4個盒子何時消失,然後淡入第五個盒子?VBA for PowerPoint中是否存在IF隱藏語句?

所以4個盒子在用戶控制下消失,一旦它們全部消失,就會自動出現第五個盒子。這可能嗎?

+0

不知道PPT腳本的情況下,但大多數動畫處理有他們完成信號時的一些方式。計算您收到多少「已完成」通知,並且當您點擊4時,在第5個框中開始淡出。 – 2013-03-18 21:21:20

+1

你不必寫宏來做到這一點。在PP中有作爲標準解決方案的動畫控制。爲什麼比VBA? – 2013-03-18 21:46:00

+0

你如何計算完成的通知? – 2013-03-20 17:27:46

回答

0

不需要vba。給第五個動畫,然後將其設置爲After Previous。如果需要,添加延遲。它會在之前(即第四個形狀)消失後生成動畫。

+0

我試過After Previous,但問題是當4盒子消失時,人們隨機選擇。如果首先點擊觸發第五個盒子入口的盒子,則無論其他三個盒子是否被點擊,它都會出現。 – 2013-03-20 17:27:27

0

啊。感謝澄清。

在這裏你去:

' Give each of the four shapes an action setting of Run Macro: HideMe 

Sub HideMe(oSh As Shape) 
    Dim oSl As Slide 

    ' hide the clicked shape 
    oSh.Visible = False 

    ' test to see if all four shapes are hidden now 
    ' edit to reflect the actual names of the shapes in use 

    Set oSl = oSh.Parent ' the slide containing the clicked shape 
    With oSl 
     If Not .Shapes("Rectangle 3").Visible Then 
      If Not .Shapes("Rectangle 4").Visible Then 
       If Not .Shapes("Rectangle 5").Visible Then 
        If Not .Shapes("Rectangle 6").Visible Then 
         ' they're all hidden, so make the new shape visible 
         .Shapes("Rectangle 7").Visible = True 
        End If 
       End If 

      End If 
     End If 
    End With 

End Sub 

Sub MakeMeInvisible() 
' run this after selecting the final shape 
' to make it invisible to begin with 
    ActiveWindow.Selection.ShapeRange(1).Visible = False 
End Sub