Background & Text Color for TextBox in VBA 
Author Message
 Background & Text Color for TextBox in VBA

this worked for me:

Sub MyTextbox()
  Dim shp As Shape
  Dim r As Long
  Dim c As Long
  Dim w As Long
  Dim h As Long
    r = 2
    c = 3
    w = Cells(1, 1).Resize(1, c).Width
    h = Cells(1, 1).Resize(r, 1).Height

  Set shp = Worksheets(1).Shapes.AddTextbox( _
  msoTextOrientationHorizontal, w, h, 200, 50)
  shp.TextFrame.Characters.Text = "I want a red TextBox"
  shp.TextFrame.Characters.Font.ColorIndex = 6
  shp.Fill.ForeColor.RGB = vbRed
  shp.Fill.Solid
  shp.Visible = msoCTrue
  Application.ScreenUpdating = True

 End Sub

Regards,
Tom Ogilvy


Quote:

> Hi,

> Please some advice how to set background and text color in followig code
> example.

> Sub MyTextbox()
>     r = 2
>     c = 3
>     w = Cells(1, 1).Resize(1, c).Width
>     h = Cells(1, 1).Resize(r, 1).Height

>     Worksheets(1).Shapes.AddTextbox(msoTextOrientationHorizontal, w, h,
200,
> 50).TextFrame.Characters.Text = "I want a red TextBox"

>  End Sub

> Thanks in advance,
> Hans



Wed, 01 Sep 2004 22:30:56 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Add background color to textbox VBA

2. Text Color / Background Color

3. Printing Text in textboxes without the text box background

4. Change background color of a selected line in a textbox

5. Textbox background color depend on value

6. Textbox - background color

7. Need to type white text on black background in a shadowed textbox

8. Dynamically changing cell background colors with VBA

9. VBA-Change desktop background color?

10. Background Color VBA Question


 
Powered by phpBB® Forum Software © phpBB Group