2017-02-20 746 views
0

我遇到了更改我的CommandButton颜色的问题。在电子表格中,我将设计按钮添加为窗体或ActiveX。Excel VBA为CommandButton更改颜色

然后在VBA我尝试:

Activesheet.shapes("CommandButton1").visible = false 

这一个工作就好了。

但后来我尝试:

Activesheet.shapes.Fill.ForeColor.RGB = RGB(220, 105, 0) 

它运行没有错误,但没有改变;颜色保持原样。

你能帮我解决吗?

+0

'Shapes'是一个集合,你需要指定你正在使用哪个索引。另外,表单和ActiveX控件是完全不同的,并且根本不起作用。 –

回答

0

试试看这样的:

ActiveSheet.CommandButton1.BackColor = RGB(220, 105, 0) 
+0

它工作后,我添加Activesheet.CommandButton1.BackColor = RGB(220,105,0)。我应该之前尝试过。谢谢 –