我有2张照片用于定义循环赛中的球队。当你点击一个表示获胜者时,另一个"灰色"使用以下代码
Sub W1One()
Dim a As Shape
Set a = ActiveSheet.Shapes("W1SeaEagles")
a.Fill.PictureEffects.Insert(msoEffectSaturation).EffectParameters(1).Value = 0.05)
End Sub
然而,这是不可逆的,即。如果我点击错误的一个,我想点击另一个来执行相反的反应。
我正在思考这个问题:
Sub W1One()
Dim a As Shape
Dim b As Shape
Set a = ActiveSheet.Shapes("W1SeaEagles")
Set b = ActiveSheet.Shapes("W1Rabbitohs")
If (a.Fill.PictureEffects.Insert(msoEffectSaturation).EffectParameters(1).Value = 100) Then
a.Fill.PictureEffects.Insert(msoEffectSaturation).EffectParameters(1).Value = 0.05
b.Fill.PictureEffects.Insert(msoEffectSaturation).EffectParameters(1).Value = 100
Else: a.Fill.PictureEffects.Insert(msoEffectSaturation).EffectParameters(1).Value = 100
b.Fill.PictureEffects.Insert(msoEffectSaturation).EffectParameters(1).Value = 0.05
End If
End Sub
它不起作用。另一张图(b)是灰色的,但是' a'去超颜色!
答案 0 :(得分:0)
您需要删除现有的饱和度,而不是插入其他饱和度。
让两张图片调用相同的宏W1One()并尝试:
Sub W1One()
Dim a As Shape
Dim b As Shape
Set a = ActiveSheet.Shapes("W1SeaEagles")
Set b = ActiveSheet.Shapes("W1Rabbitohs")
If Application.Caller = "W1SeaEagles" Then
With b.Fill.PictureEffects
While .Count > 0
.Delete (1)
Wend
End With
a.Fill.PictureEffects.Insert(msoEffectSaturation).EffectParameters(1).Value = 0.05
Else
With a.Fill.PictureEffects
While .Count > 0
.Delete (1)
Wend
End With
b.Fill.PictureEffects.Insert(msoEffectSaturation).EffectParameters(1).Value = 0.05
End If
End Sub
在我的测试中切换饱和度。