Application.Font32Ex method (Project)

Sets the font for the text in the active cells, where the text color can be a hexadecimal value.

Syntax

expression. Font32Ex( _Name_, _Size_, _Bold_, _Italic_, _Underline_, _Color_, _Reset_, _CellColor_, _Pattern_, _Strikethrough_ )

expression An expression that returns an Application object.

Parameters

Name Required/Optional Data type Description
Name Optional String The name of the font.
Size Optional Integer The size of the font in points.
Bold Optional Variant True if the font is bold.
Italic Optional Boolean True if the font is italic; otherwise, False.
Underline Optional Boolean True if the font is underlined; otherwise, False.
Color Optional Long The color of the font. Can be a hexadecimal RGB value, where red is the last byte. For example, &H0000FF is red.
Reset Optional Boolean True if the font is reset to its default characteristics. All other arguments are ignored. The default value is False.
CellColor Optional Variant The color of the cell. Can be a hexadecimal RGB value, where red is the last byte. For example, &HFFFF99 is cyan.
Pattern Optional Variant Background pattern of the cell. Can be one of the PjFillPattern constants.
Strikethrough Optional Variant True if the font is the strikethrough format.

Return value

Boolean

Remarks

For the Color and CellColor parameters, the decimal value -16777216 sets the color to automatic (black for text and white for the cell color).

Example

The following example formats text in the selected cells using 16-point Tahoma in a pink color, and sets the cell color to a light yellow.

Sub FormatTahoma16() 
    Font32Ex Name:="Tahoma", Size:=16, Color:=&HFF88FF, CellColor:=&H99FFFF 
End Sub

Note

If you use any of the PjColor constants for the Color or CellColor parameters, the color will be nearly black. For example, the value of pjGreen is 9, which in the Fon32Ex method is a very dark red. To use only the sixteen colors available with PjColor constants, use the FontEx method.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.