user2489758
user2489758

Reputation: 13

How to set Color for the text box in visual basic Word macro

I tried to change background color of text box. These are not working:

Me.TextBox1.ForeColor = &HFF& 
Me.TextBox1.BackColor = &H8000000D 

I did not find any field corresponding to color. My text box:

Set Box = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=50, Top:=50, Width:=440, Height:=300)
Box.WrapFormat.Type = wdWrapSquare

Upvotes: 1

Views: 13727

Answers (1)

CuberChase
CuberChase

Reputation: 4518

You are not having any success with the color for your text box possibly for two reasons.

Firstly, you create your text box correctly using the shapes object but then you when you set the colour you use Me.TextBox1. Since you have created the object using the Box variable it is better to use this variable to set the colour.

The second problem is that the Shape object uses the Fill property to set the colour. Therefore you simply need to use the following code after creating the Box:

Box.Fill.ForeColor = &HFF&
Box.Fill.BackColor = &H8000000D

Upvotes: 1

Related Questions