VBA & Macro Problems

Change Text Color in a Word VBA Shape

John WilsonJohn Wilson Nov 20, 2026 868 views

Question details

Set the color and size of text inside an inserted Word shape using VBA without relying on TextEffect.

Change Text Color in an Inserted Shape with Word VBA
Product
Microsoft Word
Device & OS
not provided
Scenario
A user is formatting a number inside an inserted triangle shape with a Word VBA macro.
Observed behavior
Using TextEffect.FontSize with the standard shape causes an error, and the triangle may appear in an unexpected color.
Before you start

Open Word and make sure you can access the VBA editor from the Developer tab. Test the macro in a new blank document to check whether existing default shape formatting affects the result.

Solution 1Recommended

Format the Shape Text with TextFrame.TextRange

Use the shape's text range to set the number's font color and size, and format the triangle's outline separately.

TextFrame.TextRange controls ordinary text inside a shape. TextEffect is intended for WordArt and is not the appropriate way to set the font size of a standard shape.

1
Open the VBA editor

In Word, open Developer > Visual Basic, then select Insert > Module.

2
Add the macro

Paste this example into the module: Sub AddTriangleWithBlackText() Dim shp As Shape Set shp = ActiveDocument.Shapes.AddShape( _ Type:=msoShapeIsoscelesTriangle, Left:=72, Top:=72, _ Width:=100, Height:=80) With shp .TextFrame.TextRange.Text = "1" .TextFrame.TextRange.Font.ColorIndex = wdBlack .TextFrame.TextRange.Font.Size = 8 .TextFrame.TextRange.ParagraphFormat.Alignment = wdAlignParagraphCenter .Line.Visible = msoTrue .Line.ForeColor.RGB = RGB(0, 0, 0) End With End Sub

3
Run and inspect the shape

Place the cursor inside the macro and select Run > Run Sub/UserForm. Check that the number and triangle outline appear black; adjust Width or Height in the macro if the text needs more room.

Format the Shape Text with TextFrame.TextRange
Text and outline are separate: Font.ColorIndex changes the text, while Line.ForeColor changes the outline. Setting Line.Visible to msoFalse hides the outline rather than changing the text color.
Free Microsoft Office alternative

Edit Shape Text in WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for editing documents and formatting shape text. Its Microsoft Word format compatibility helps you move documents between suites, though it does not fix errors in Microsoft Word VBA macros.

Format text and shapes in WPS Writer using familiar document-editing tools.Open and edit Microsoft Word formats, including DOC and DOCX.Use a free, lightweight office suite for everyday documents.Move existing documents to WPS Office with a familiar interface.
microsoft office alternative - wps office

Frequently Asked Questions

How do I make the text inside a Word shape black with VBA?

Set the shape's text range color with shp.TextFrame.TextRange.Font.ColorIndex = wdBlack, where shp is your Shape object.

Why does TextEffect.FontSize cause an error?

TextEffect is intended for WordArt rather than ordinary text in a standard shape. Use shp.TextFrame.TextRange.Font.Size = 8 to set the text size.

How do I change the triangle outline without changing its text?

Set shp.Line.Visible = msoTrue and shp.Line.ForeColor.RGB = RGB(0, 0, 0). Use TextFrame.TextRange.Font to format the text separately.

Why does the shape look different in another document?

The document may have different default shape formatting. Run the macro in a new blank document and explicitly set the font and outline colors to compare the results.