+ Reply to Thread
Results 1 to 3 of 3

Font.Color - syntax error ?

  1. #1
    Linda Edlund
    Guest

    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

  2. #2
    Peter T
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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




  3. #3
    Linda Edlund
    Guest

    Re: 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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1