Excel VBA 更改命令按钮的颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42350388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 10:44:41  来源:igfitidea点击:

Excel VBA changing color for CommandButton

excelvbaexcel-vbacommandbutton

提问by Matthew C

I'm having problem with changing colors of my CommandButton. In the spreadsheet I add design button as form or ActiveX.

我在更改CommandButton. 在电子表格中,我将设计按钮添加为表单或 ActiveX。

Then in VBA I try:

然后在 VBA 中我尝试:

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

This one works just fine.

这个工作得很好。

But then I try:

但后来我尝试:

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

It runs without error but nothing changes; color remains as it was before.

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

Could you please help me with this?

你能帮我解决这个问题吗?

回答by pokemon_Man

Just try it like this:

试试这样:

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