Fix Green Text in a Word VBA Macro on Mac
Question details
The user needs to correct an issue where a portion of a VBA macro procedure name appears green and fails to execute correctly in Word for Mac.
- Product
- Word for Mac
- Device & OS
- Mac
- Scenario
- Writing or editing a custom VBA macro and assigning it a procedure name that includes an apostrophe.
- Observed behavior
- The VBA editor interprets the apostrophe in the procedure name as the start of a comment, turning the text green and causing a syntax error when trying to run or call the macro.
Open your macro-enabled document (.docm) in the Word for Mac application and ensure the Developer tab is visible on your ribbon so you can quickly access the Visual Basic editor.
Rename the Procedure and Update Call Statements
Remove the apostrophe from the macro name to prevent the editor from treating the code as a comment.
In the VBA programming language, an apostrophe (') is the reserved character for initiating a comment. When you place an apostrophe inside a procedure name, VBA immediately stops reading it as a command and colors the remaining text green. Removing this punctuation mark resolves the syntax error.
Click on the Developer tab in Word for Mac, select 'Visual Basic', and find the Sub line where your procedure name is currently defined.
Delete the apostrophe from the macro name in the Sub declaration. For example, change 'Sub We'llRun()' to 'Sub WellRun()'.
Search through your entire VBA project for any 'Call' statements that reference the old macro name, and manually update them to match the new, apostrophe-free name.
Click the 'Run' button in the VBA editor toolbar to verify that the green text issue is resolved and the macro executes normally.

Seamlessly Manage and Edit Macros in WPS Office
WPS Office provides robust built-in support for VBA macros, allowing you to edit, troubleshoot, and run your VBA scripts just like in Microsoft Word. It offers a highly compatible and familiar environment for managing macro-enabled documents.
- 1. Open your macro-enabled document: Launch WPS Office and open your .docm file that contains the VBA scripts you wish to edit.
- 2. Access the Developer Tab: Navigate to the 'Developer' tab located on the top ribbon of the WPS Writer interface.
- 3. Open the VBA Editor: Click on 'Visual Basic' or 'Macros' to access the code editor, where you can easily rename procedures and correct syntax errors.

Frequently Asked Questions
Why does text suddenly turn green in the VBA editor?
In VBA, green text indicates a comment. The editor automatically turns any text following an apostrophe (') green, signaling that it is a developer note and will be ignored by the compiler during code execution.
Can I use spaces in a Word macro name?
No, VBA procedure names cannot contain spaces. To make multi-word names readable, you should use underscores (e.g., My_Macro_Name) or CamelCase capitalization (e.g., MyMacroName).
What other characters are forbidden in VBA procedure names?
VBA procedure names cannot include characters such as periods (.), exclamation marks (!), at symbols (@), ampersands (&), dollar signs ($), or hashtags (#). Additionally, the name must always begin with a letter.
Will renaming the macro break my custom document buttons?
Yes. If you have a custom shape, button, or ribbon shortcut assigned to the old macro name, it will stop working after the rename. You must right-click the button, select 'Assign Macro', and link it to the newly updated procedure name.




