logo
search
Others

How to Set VBA-Generated HTML Email Font Color to Automatic

Maira MehtabMaira Mehtab Sep 20, 2026 869 views

Question details

The user wants to set the text color of an HTML email generated via a VBA script to 'Automatic' (default/black), but the email does not render the color as expected when using 'font-color' in the body style.

Product
VBA Scripting
Device & OS
not provided
Scenario
Generating an HTML-formatted email using a VBA macro and attempting to apply a specific text color to the email body.
Observed behavior
The intended font color fails to appear in the generated email because 'font-color' is an invalid CSS property for HTML rendering.
Before you start

Ensure you have access to your VBA code editor (typically accessed via Alt + F11) and basic familiarity with how your macro constructs HTML strings.

Solution 1Recommended

Use the Standard CSS Color Property

Replace the incorrect 'font-color' attribute with the standard CSS 'color' property within your inline styles for accurate rendering.

In standard HTML and CSS, there is no property named 'font-color'. To change text color, the correct property is simply 'color'. Using invalid properties will cause email clients to ignore the styling entirely.

1
Open the VBA Editor

Press Alt + F11 to open your VBA environment and locate the script responsible for generating the HTML email.

2
Locate the style definitions

Find the section of your code where the HTML body string is constructed, specifically looking for `<body style=...>` or inline style attributes.

3
Update the CSS syntax

Change any instance of `font-color: black;` to `color: black;`. For targeting specific text, wrap it in a span: `<span style="color: black;">your text</span>`.

4
Test the macro

Run the VBA macro to generate a test email and verify that the text color now displays correctly.

Free Microsoft Office alternative

Write and Execute VBA Scripts Seamlessly with WPS Office

If you frequently work with VBA macros to automate tasks like sending HTML emails, consider WPS Office. It is a robust, highly compatible alternative to Microsoft Office that supports standard VBA scripting, allowing you to run your existing macros without the high subscription costs.

  1. 1. Download WPS Office: Visit the official WPS website to download and install the free WPS Office suite.
  2. 2. Open your macro-enabled file: Launch WPS Spreadsheets and open your existing .xlsm or .docm file containing your VBA code.
  3. 3. Access the VBA Editor: Navigate to the Developer tab and click on 'Visual Basic' (or press Alt + F11) to view, edit, and run your VBA macros seamlessly.
Fully compatible with Microsoft Office formats, including macro-enabled workbooks (.xlsm)Built-in support for VBA macros and advanced Excel-like scriptingFree, lightweight, and fast to installFamiliar user interface ensuring a seamless migration process
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't 'font-color' work in my HTML email VBA script?

In standard HTML and CSS, 'font-color' is not a valid property. The correct CSS property to change text color is simply 'color'. Invalid properties are automatically ignored by email client rendering engines.

How do I set the email text color to 'Automatic' using VBA?

In HTML, 'Automatic' typically translates to the default text color of the viewer's email client, which is usually black. You can explicitly set it to black using the CSS `color: black;` property or the legacy `<font color="black">` tag.

Are FONT tags still supported in modern HTML emails?

Yes. While `<font>` tags are heavily deprecated in standard modern web development, they are still widely used and highly supported in HTML emails. This is because many desktop and mobile email clients have fragmented or limited support for standard CSS.