PDA

View Full Version : Change BackGround Color of Label (Active X Control)



sprivitor
01-05-2018, 03:55 AM
Hi All - New user here. I have a Label on on my slide that I wish to change the color. How do I do it?

Label1 is a simple rectangular control. It fills the Label with "Hello World" text, then errors on the color change. And it's an obvious error that states "object does not support this property or method". My goal is to put the text on the screen and change the background color of it. There's probably a better way to do this and I'd be thankful for any suggestions.???

ActivePresentation.Slides(1).Shapes("Label1").OLEFormat.Object.Caption = "Hello World"
ActivePresentation.Slides(1).Shapes("Label1").OLEFormat.Object.Fill.BackColor.RGB = RGB(255, 183, 2)

John Wilson
01-05-2018, 04:57 AM
You need to work in HexaDecimal


ActivePresentation.Slides(1).Shapes("Label1").OLEFormat.Object.BackColor = &H2B7FF ' = RGB(255,183,2)

You can also say

ActivePresentation.Slides(1).Shapes("Label1").OLEFormat.Object.BackColor = RGB(255,183,2)

In the second example the RGB value will give a long which will be converted to Hex for you. I would use method 1 if you are able, 2 is easier but one day MSFT will change the settings and it will fail!!

sprivitor
01-05-2018, 09:40 PM
Thanks !!! The .FILL was what was giving me the problem. After leaving it off, as you suggested, it works great!