VBA, give colors to buttons

Hello guys.

I have 15 buttons on a form. Below it is a picture of my form with the buttons.

UserForm  
They are named like:

CommandButton1
CommandButton2
CommandButton3
....
....
...
CommandButton15

Respectively.....

I would like (with a vba macro) to give the 15 buttons the same colors as the highlight color options in word, like in the picture below
Highlight ColorsAny ideas of how I achieve this?
LVL 1
New_AlexAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dagesiCommented:
I don't see BackColor as an option for CommandButton (which could just be me); maybe you'd be best off utilizing a different object type that has BackColor and specifying OnClick as well for the object.
0
New_AlexAuthor Commented:
Hi Dagesi.

There is a BackColor option for CommandButton in the design Properties window.

It does not have to be a button. A select box could do the same.

How do I change the color of a CommandButton is the main question,,,

Any ideas?
 
0
karthika_ctsCommented:
if you are supposed to use rectangular shape (similar to work as button), here goes the code
With ActiveWorkbook.Sheets(ASheet).Rectangles.Add(280, 30, 160, 30)
    .OnAction = "CODING"
    .Caption = "MAIN MENU"
    .Font.Size = 25
    .Font.Underline = xlUnderlineStyleSingle
    .Name = "CODING"
    .Interior.Color = RGB(255, 255, 255)
    .Border.Color = RGB(255, 255, 255)
End With
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

karthika_ctsCommented:
Here's another way..

Put textbox over command button caption. Set the backolor of the text box to the color of the
command button, set borders to None. Change the ForeColor of the Text box.

If you use this, don't forget to add
Private Sub Text1_Click()
Command1_Click
End Sub

http://www.bigresource.com/Tracker/Track-vb-chjX4UrVgl/
0
GrahamSkanRetiredCommented:
Not sure why this in the JScript Zone.

The BackColor property for a VBA userform Command button is a Long, which can express nearly 17 million colours in RGB format.

The .ColorIndex in an Enum with about 16 values for colours.

Unfortunately, there is no simple automatic way to derive the RGB value from the from the index, i.e. to convert .ColorIndex to .BackColor.

I would advise experimentation, working in Hex.

Red = &H00FF0000
Green = &H0000FF00
Blue = &H000000FF
Yellow =  &H00FFFF00
Mid Grey = &H00777777

Alternatively, some graphics packages will report the colour value at a point, so you could open your jpg there and thus get the values
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dagesiCommented:
>New_Alex...
I think I see... I thought you were creating a form in another software (such as Access) that would be similar to Word's color pallette, not that you wanted to create one on a form apparently *in* Word.
0
New_AlexAuthor Commented:
Thanks GrahamSkan. This is the theory behind colors I needed to know. Then I may use .Jpg image as background with mouse click regions.

Thanks karthika_cts and dagesi as well for the value they added in my thread.

dagesi, that is right. I was looking for a word VBA solution within word.

Take care and
Love
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JScript

From novice to tech pro — start learning today.