How to Change the Fill Color of an Excel Button with VBA in WPS Spreadsheets
Question details
The user needs to change an Excel button's fill color through VBA and must determine whether the button is a Form Control or an ActiveX command button because each type requires different VBA properties.

- Product
- WPS Spreadsheets
- Device & OS
- not provided
- Scenario
- The user is editing a macro-enabled Excel workbook and wants to change the fill color of a button programmatically using VBA.
- Observed behavior
- The button color needs to be changed with VBA. A true fill color is available for ActiveX command buttons through BackColor, while Form Control buttons support font color changes instead.
Check whether your button is a Form Control or an ActiveX command button, and make sure macros are enabled in WPS Spreadsheets. Keep the workbook name, worksheet name, and button name available because the VBA code must reference them exactly.
Set the BackColor of an ActiveX Command Button with VBA
Use this method when you need to change the actual button face color. ActiveX command buttons expose a BackColor property that controls the fill color directly.
ActiveX command buttons are OLE objects, and their BackColor property controls the button face color. This is the correct method when you specifically need a fill color change rather than only a font color change.
Open the macro-enabled workbook in WPS Spreadsheets and press Alt+F11 to open the VBA editor.
Click Insert > Module in the VBA editor menu to create a new module.
Paste the following VBA and replace Sheet1 and CommandButton1 with your worksheet and button name: Sub ChangeActiveXButtonColor() Dim btn As OLEObject Set btn = Sheet1.OLEObjects("CommandButton1") btn.Object.BackColor = RGB(255, 0, 0) End Sub
Place the cursor inside the subroutine and press F5, or click Run > Run Sub/UserForm in the VBA editor.
Go to File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm) so the VBA code is saved with the workbook.

Change a Form Control Button's Font Color with VBA
Use this method when your button is a Form Control. Form Control buttons do not expose a direct fill color property, but you can change the font color with VBA.
Change Excel Button Colors with VBA in WPS Spreadsheets
WPS Spreadsheets includes VBA macro support and Excel-compatible Form Control and ActiveX buttons, so you can change button fill color or font color using the same VBA object model and save the workbook as an Excel Macro-Enabled Workbook.
- 1. Open your workbook: In WPS Spreadsheets, open the Excel workbook that contains the button, or create a new workbook and insert your button from the Developer tab.
- 2. Enable macros: If prompted, click Enable Content or enable macros in WPS Spreadsheets so VBA code can run.
- 3. Open the VBA editor: Press Alt+F11 to open the WPS VBA editor, then click Insert > Module.
- 4. Paste and run the button color macro: Paste the ActiveX BackColor or Form Control font color VBA code, adjust the button name and RGB values, then press F5 to run it.
- 5. Save as a macro-enabled workbook: Go to File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm) to keep the macro.

Frequently Asked Questions
Can I change the fill color of a Form Control button in Excel or WPS Spreadsheets?
Form Control buttons do not expose a direct fill color property in VBA. You can change the font color using btn.Font.Color, or use an ActiveX command button and set btn.Object.BackColor for a true fill color change.
How do I open the VBA editor in WPS Spreadsheets?
Press Alt+F11, or use the Developer tab and click Visual Basic. If the Developer tab is not visible, enable it in WPS Spreadsheets options first.
Why does my ActiveX button color macro not run?
Check that macros are enabled, the worksheet name and OLE object name match the code exactly, and the workbook is saved as an Excel Macro-Enabled Workbook (.xlsm). Also confirm the button is an ActiveX command button and not a Form Control.
Does WPS Office support Excel macro-enabled workbooks?
Yes, WPS Spreadsheets can open and save .xlsm macro-enabled workbooks and provides a VBA editor for Excel-compatible macros, although some advanced ActiveX features may behave differently.
What is the difference between Form Control and ActiveX buttons?
Form Control buttons are simpler and use Assign Macro. ActiveX command buttons are OLE objects with properties such as BackColor, so they can be controlled more directly through VBA.




