我使用背景擦拭物进行演示,这些擦拭物是流程图,带有文本“wipey”用于黄色擦拭物和“wipeb”用于蓝色擦拭物。在制作训练幻灯片的动画时,我将擦拭布放在前面,透明度为 0.75。一旦擦除动画顺序正确并且擦除正确放置,我将擦除移动到文本后面,透明度为 0。我的 Wipe_Back 宏工作正常,但我的 Wipe_Front 宏在每次调用时只得到一些擦除。我必须多次调用它才能使所有形状向前移动。宏几乎相同,所以我不确定我做错了什么,但我是 VBA 新手!这两个宏都显示在下面,我也愿意接受有关代码中更优雅实践的建议。
Wipe_Back(似乎有效):
Sub Wipe_Back()
Dim sld As slide
Dim shp As Shape
Dim str As String
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.Type = msoAutoShape Then
If shp.HasTextFrame Then
If shp.TextFrame.TextRange = "wipey" Then
shp.Fill.Transparency = 0
shp.ZOrder msoSendToBack
'shp.Fill.Transparency = 0.75
'shp.ZOrder msoBringToFront
End If
If shp.TextFrame.TextRange = "wipeb" Then
shp.Fill.Transparency = 0
shp.ZOrder msoSendToBack
'shp.Fill.Transparency = 0.75
'shp.ZOrder msoBringToFront
End If
End If
End If
Next shp
Next sld
End Sub
Wipe_Front 不能始终如一地工作:
Sub Wipe_Front()
Dim sld As slide
Dim shp As Shape
Dim str As String
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.Type = msoAutoShape Then
If shp.HasTextFrame Then
If shp.TextFrame.TextRange = "wipey" Then
'shp.Fill.Transparency = 0
'shp.ZOrder msoSendToBack
shp.Fill.Transparency = 0.75
shp.ZOrder msoBringToFront
End If
If shp.TextFrame.TextRange = "wipeb" Then
'shp.Fill.Transparency = 0
'shp.ZOrder msoSendToBack
shp.Fill.Transparency = 0.75
shp.ZOrder msoBringToFront
End If
End If
End If
Next shp
Next sld
End Sub