ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Font.Color - syntax error ? (https://www.excelbanter.com/excel-programming/358812-font-color-syntax-error.html)

Linda Edlund

Font.Color - syntax error ?
 
Set shp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 10, 10, 50, 50)
With shp

.Fill.ForeColor.RGB = RGB(255, 255, 255)

.TextFrame.Characters.Font.Color = RGB(0, 0, 0)

End With

The code:
.TextFrame.Characters.Font.Color = RGB(0, 0, 0)
gives results <grey not <black why ?
is there any syntax error ?

Many thanks in advance

Peter T

Font.Color - syntax error ?
 
That looks fine to me on the basis of what you've posted.

Guessing, at the time you apply the font colour does your shape have a
textframe and text. If not the code would error possibly masked if under on
error resume next. Thereafter the font colour would remain same as your
default for new shapes.

If(?) that's what your doing, eg an empty text box with font pre-formatted,
there's another way.

Set shp = ActiveSheet.Shapes.AddTextbox(msoShapeRectangle, _
10, 10, 50, 50)
With shp

.Fill.ForeColor.RGB = RGB(255, 255, 255)

.DrawingObject.Font.Color = RGB(255, 0, 0) 'red for testing
.Visible = True
' or
'.DrawingObject.Font.ColorIndex = xlAutomatic '3 for red
.Select
End With

This should add an empty text box and select, now type in some text.

Regards,
Peter T

PS, although .forecolor can be RGB formatted with any one of 16 million
colours, font can only accept one of the 56 palette colours or automatic,
when applying an rgb the closest match in the palette will be applied.




"Linda Edlund" wrote in message
7...
Set shp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 10, 10, 50, 50)
With shp

.Fill.ForeColor.RGB = RGB(255, 255, 255)

.TextFrame.Characters.Font.Color = RGB(0, 0, 0)

End With

The code:
.TextFrame.Characters.Font.Color = RGB(0, 0, 0)
gives results <grey not <black why ?
is there any syntax error ?

Many thanks in advance




Linda Edlund

Font.Color - syntax error ?
 
Thank you very much Peter

I've missed this information about 56 colours available for font.color
I had change <black in my pallete to some other colour earlier, so it was
the risen
Now it's fixed

Thanks again


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

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