跳到主要內容

如何在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

尖端:您可以訪問此網站: 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選項卡為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