ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text color in textbox (https://www.excelbanter.com/excel-programming/450232-text-color-textbox.html)

clvrbas

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


All times are GMT +1. The time now is 11:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com