View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 587
Default Text color in textbox

hi Chris,

if you do not want the text to be modified why not use a Label.

Set shp = ActiveSheet.Shapes.AddLabel(msoTextOrientationHori zontal, 100, 100,
200, 50)

for the font color try with:

With shp
.TextFrame2.TextRange.Characters.Font.Fill.ForeCol or.RGB = RGB(255, 0, 0)

isabelle

Le 2014-07-22 17:22, clvrbas a écrit :
Hello there!

I am trying to insert a text box using VBA. I have been able to get all
components of the text box to work except changing the font color. The
other hurdle i'm struggling with is trying to keep the sheet locked, but
allowing the user to still be able to edit this object only, and not all
the other objects on the sheet. In need of more experienced VBA
writers.

Sub add_textbox_VBA()

Dim shp As Shape
ActiveSheet.Unprotect "password"
Set shp = ActiveSheet.Shapes.AddTextBox(msoTextOrientationHo rizontal,
100, 100, 200, 50) ' add shape
With shp
TextFrame.Characters.Text = "Example" ' add text to display
Top = Range("B2").Top ' adjust top
Left = Range("B2").Left 'adjust left
TextFrame.AutoSize = True ' turn on autosize
TextEffect.FontSize = 16
TextEffect.FontName = "Arial Black"
Fill.ForeColor.RGB = RGB(0, 56, 150) 'choose fill color
Line.Weight = 1 ' adjust width
Line.ForeColor.RGB = RGB(0, 56, 150) ' choose color
Line.DashStyle = msoLineSolid ' choose style
End With

ActiveSheet.Protect "password", DrawingObjects:=False, Contents:=False,
Scenarios:=False
End Sub