跳到主要内容

如何在Excel中更改ActiveX控件按钮的颜色?

在Excel中,当您插入命令按钮时,默认情况下按钮的颜色为灰色。 但是有时,您需要将灰色更改为漂亮的颜色,以使工作表更专业。 今天,我可以向您介绍一些快速技巧,以更改Excel中按钮的颜色。

通过更改属性来更改ActiveX控件按钮的颜色
使用VBA代码更改ActiveX控件按钮的颜色


通过更改属性来更改ActiveX控件按钮的颜色

通常,在Excel中,按钮有两种类型,一种是 表格控制 按钮,另一个是 ActiveX控件 按钮。 如果该按钮是“表单控制”按钮,则只能更改其字体颜色,而不能更改背景颜色。 您只需更改ActiveX控件按钮的背景色即可。 请这样做:

1. 插入 ActiveX控件 通过单击按钮 开发商 > 插页,然后选择 命令按钮ActiveX控件 部分,请参见屏幕截图:

文档更改按钮颜色1

备注:如果 开发商 标签未显示在功能区中,您可以单击 文件 > 附加选项 > 自定义功能区,然后检查 开发商 在右窗格中显示 开发商 标签。

2。 然后拖动鼠标以绘制一个按钮。

文档更改按钮颜色1

3。 然后选择按钮并右键单击,选择 查看房源 从上下文菜单中,然后弹出 查看房源 对话框中,单击 拼音 标签,然后单击 背景色 下拉列表中选择您喜欢的一种颜色,请参见屏幕截图:

文档更改按钮颜色3 -2 文档更改按钮颜色4

4。 然后关闭对话框,并且命令按钮的颜色已更改如下:

文档更改按钮颜色1

5。 最后,退出 设计模式 通过点击 开发商 > 设计模式 使按钮正常使用。


使用VBA代码更改ActiveX控件按钮的颜色

如我们所见,Excel在“属性”对话框中提供了几种颜色供我们应用。 通过以下简单的VBA代码,可以选择很多颜色。

1. 插入命令按钮,然后右键单击,然后选择 查看代码 从上下文菜单中,查看屏幕截图:

文档更改按钮颜色1

2。 然后一个 Microsoft Visual Basic for Applications窗口 将显示,请参见屏幕截图:

文档更改按钮颜色1

3。 然后复制并粘贴以下简单代码脚本: 命令按钮 1.BackColor = 12713921 进入两个代码之间的窗口,请参见屏幕截图:

文档更改按钮颜色1

请注意: 在以上代码脚本中, 命令按钮 1 是按钮的名称和数字 12713921 MS访问,它们都是可变的,您可以根据需要进行更改。

4. 然后按 F5 键来运行此代码,并且您的按钮颜色已立即更改。

文档更改按钮颜色1

Tips::您可以访问此网站: http://www.endprod.com/colors/ 查看更多 MS访问号 颜色值,可能有数百种颜色可以使用。 打开网站后,您只需要选择一种颜色,然后在MSAccess牧民下面复制相应的编号,然后在代码脚本中替换上面的编号即可。

文档更改按钮颜色1

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thanks for this information (especially the color guide resource). But can we take it one step further? Are there ways to use code to make the button look more like a button? (shadow, bevel, etc) I know how to design a shape the way I want it and then assign a macro to it. But doing that seems to me to be a workaround at best. I'd prefer to do it with code if it's possible.
This comment was minimized by the moderator on the site
I want to colour command button for specific time. like when i enter code in button, button color would be change for 40 minutes and than normal
This comment was minimized by the moderator on the site
hey, when i right clikck, it didnt show propperties so I chose properties from the Developer tool bar, and I didnt get options like backcolor. what should i do?
This comment was minimized by the moderator on the site
First click on DESIGN MODE under devloper tab, now right click on activex button. Now properties is visible
This comment was minimized by the moderator on the site
First click on design mode under devloper tab then select button and right click. Now properties option is visible ;-)
This comment was minimized by the moderator on the site
This works for a Toggle Button ...I expect a simple Command Button would be similar. With ToggleButton1 If .Value Then .ForeColor = RGB(0, 0, 0) .BackColor = RGB(0, 255, 0) .Caption = "Caption if toggled on." Else .ForeColor = RGB(0, 0, 0) .BackColor = RGB(255, 255, 0) .Caption = "Caption if toggled off" End If End With
This comment was minimized by the moderator on the site
I'm trying to find a way to use a command button or toggle buttons to change the forecolor from white to green. Is there a simplistic way to do that?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations