2017-02-20 801 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)。我應該之前嘗試過。謝謝 –