Avatar of hindersaliva
hindersaliva
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Excel 2013 Shapes Color mystery

What I'm trying to do is
ActiveSheet.Shapes("shpPart1").Fill.ForeColor = 13998939

Open in new window


but I get a Type Mismatch error.

Can someone please explain why I'm getting this? I see that the ForeColor is a long integer but I get a Type Mismatch error. So I tried String data type and get the same error.

Sub PartShapesTEST2()

    Dim s As Shape
    Dim lngColor As Long
    
    Set s = ActiveSheet.Shapes("shpPart1")
    
    lngColor = s.Fill.ForeColor
    
    s.Fill.ForeColor = lngColor
    
End Sub

Open in new window

Microsoft ExcelVisual Basic ClassicMicrosoft Development

Avatar of undefined
Last Comment
Hakan Yılmaz

8/22/2022 - Mon
hindersaliva

ASKER
Solved it!

Should be

s.Fill.ForeColor.RGB = lngColor

even though the color is not in RGB ie. not as in (255, 0, 0)
ASKER CERTIFIED SOLUTION
Wayne Taylor (webtubbs)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Hakan Yılmaz

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61