VBA & Macro Problems

How to Customize Button Text in an Access VBA Message Box

Tauseeq MagsiTauseeq Magsi Nov 4, 2026 871 views

Question details

The user wants to change the default button labels (such as Yes, No, Cancel) on a standard VBA message box to custom text.

How to Customize Button Text in an Access VBA Message Box
Product
Microsoft Access / Office VBA
Device & OS
not provided
Scenario
Creating a VBA macro that requires specific user decisions (e.g., 'Approve' or 'Reject') rather than generic Yes/No responses.
Observed behavior
The standard VBA MsgBox function uses fixed button labels based on system defaults and does not provide a native parameter to apply custom captions.
Before you start

Before attempting to customize message box buttons, ensure your VBA environment is set up and that you have permissions to insert UserForms or import third-party modules into your project.

Solution 1Recommended

Create a Custom UserForm to Replace MsgBox

Since the built-in MsgBox function cannot be directly modified, building a custom UserForm is the most reliable and native way to display custom button text.

A UserForm allows you to completely design the dialogue box from scratch. You can add your own labels, customize the appearance, and define exactly what each button says and does.

1
Insert a UserForm

Open the VBA Editor by pressing ALT + F11. Go to the top menu, click 'Insert', and select 'UserForm'.

2
Design the Message Layout

Use the Toolbox to drag and drop a 'Label' onto the form for your main message text. Adjust the font and size in the Properties Window.

3
Add Custom Buttons

Drag 'CommandButton' controls onto the form for each option. Select each button, navigate to the Properties Window, and change the 'Caption' property to your custom text (e.g., 'Approve', 'Review').

4
Write the Button Logic

Double-click each button to access its code. Write the necessary VBA logic to handle the user's choice, ending with 'Unload Me' to close the custom dialogue box.

5
Trigger the Form via Code

In your main macro, replace the standard MsgBox call with 'UserFormName.Show' to display your custom interactive prompt.

Create a Custom UserForm to Replace MsgBox
Free Microsoft Office alternative

Try WPS Office for Your Spreadsheet and Macro Needs

While Microsoft Access is part of a paid subscription, WPS Office provides a powerful, free alternative for your daily document and spreadsheet tasks. WPS Spreadsheet comes equipped with robust VBA support, allowing you to run macros and customize UserForms easily.

High compatibility with Microsoft Excel (.xlsx, .xlsm, .xls) formats.Robust VBA and Macro support in WPS Spreadsheet for task automation.Lightweight installation and a highly intuitive, familiar user interface.Free to use with comprehensive built-in PDF tools.
microsoft office alternative - wps office

Frequently Asked Questions

Why can't I pass custom names directly to the standard VBA MsgBox?

The standard VBA MsgBox is a direct wrapper for the core Windows OS message dialogue. Because it relies on predefined system templates (like vbYesNoCancel), it does not expose any parameters for custom string arrays or labels.

Can I use Windows API hooks to change MsgBox text without a UserForm?

Yes, advanced VBA developers can use Windows API functions (such as SetWindowsHookEx) to intercept the dialogue box as it is created and overwrite the button text. However, this method is highly complex and can cause Excel or Access to crash if not coded perfectly.

Does WPS Spreadsheet support VBA UserForms?

Yes, WPS Spreadsheet has robust support for VBA macros, including the ability to insert, design, and run UserForms. This allows you to easily create custom message boxes directly within WPS Office.