Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the Colour of a Button

Status
Not open for further replies.

shytott

Technical User
Aug 25, 2003
131
GB
Calling xlhelp
OK sir, here I am
Will this be terribly complicated? - Im still quite a VBA virgin!
AD
 



Please post the entire content of your question.

Be CLEAR, CONCISE & COMPLETE.

Skip,

[glasses] [red][/red]
[tongue]
 
Private Sub CommandButton1_Click()

CommandButton1.BackColor = vbRed

End Sub
 
My appologies Skip ( I was 'speaking' to xlhelp in the other forum and thought he'd be here)

Problem:
When altering a 2006 spreadsheet for use in 2007, the buttons Ive been using quite sucsessfully to navigate between a suite of 7 sheets have started now to either grow or shrink each time they are used. These buttons were created via the ControlToolbox and I was advised to use the Forms route. I've done this but the resultant buttons have an unchangable backgorund colour and I am told the only way to change this is by VBA.

Question: How do I change the background colour of a button in VBA?
AD
 



You were formerly advised to make the control a Forms control.

AFAIK, the Background Color of a Forms control cannot be changed. You CAN change the Font Color.

If you need to use a Control Toolbox control, the background can be changes as Hugh described. In addition, yoju might ALSO set the Font Size, as this seems to be the sticking point, that the Font Size was changing in the Caption.

Skip,

[glasses] [red][/red]
[tongue]
 
Hi Hugh

Ive tried that (the button I'm working with is labled 'Button 31' ie not commandbutton31 and has a space before the '31') but it hasnt worked. Ive put the code into the same module as VB did when it created the orginal button. Does it need to go somewhere speacial?
AD

 
The code I gave you applies to a CommandButton added from the ControlToolbox Toolbar and not a Button added from the Forms Toolbar.

Skip has provided the explanation for you.

regards Hugh,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top