View Single Post
  #1   Report Post  
clvrbas clvrbas is offline
Junior Member
 
Posts: 12
Default Text color in textbox

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