这是我的交互式购物车代码,但我有
错误13运行时间
Sub Freeform124_Click()
Dim NomShape As String
NomShape = Application.Caller
For Each Shape In ActiveSheet.Shapes
form.Fill.ForeColor.RGB = RGB(0, 50, 0)
Next Shape
End Sub
答案 0 :(得分:0)
代码的问题在于您使用for each Shape
循环然后编写form.fill.forecolor
。
大概。加上解析为application.caller
的字符串。
如果您可以从对象中单击宏,这是更改所有对象颜色的好方法。
Option Explicit
Sub Rechteck1_Klicken()
Dim oCaller As Object
Dim shShape As Shape
Set oCaller = ActiveSheet.Shapes(Application.Caller)
oCaller.Fill.ForeColor.RGB = RGB(100, 250, 250)
For Each shShape In ActiveSheet.Shapes
If shShape.Name <> oCaller.Name Then
shShape.Fill.ForeColor.RGB = RGB(110, 50, 0)
End If
Next shShape
End Sub