Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4362
  • Last Modified:

How do I change the color of an Excel button?

In Excel I've inserted a "button" and assigned it to a macro.  How do I change the face color of the button?  I'd like to change the face color from grey to blue.  Or better yet can I insert a picture onto the face of the grey button?  
0
shaolinfunk
Asked:
shaolinfunk
  • 6
  • 5
1 Solution
 
hiteshgoldeneyeCommented:
use this
Sheet1.CommandButton1.ForeColor = RGB(255,0,0)
0
 
hiteshgoldeneyeCommented:
sorry misunderstood
Sheet1.CommandButton1.Picture = LoadPicture("C:\hithtml\Prairie Wind.bmp")
0
 
shaolinfunkAuthor Commented:
Where do I insert that code?

When I edit a macro from within Excel it brings me into a module within Visual Basic...the module is filled with "Sub" routines...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
hiteshgoldeneyeCommented:
Put this code in a separate module and run the macro, or you can put it in any of your macros
0
 
shaolinfunkAuthor Commented:
So to "color" the buttons I have to hit a macro button to run the code?

Is there a way to have the buttons be colored as soon as the Excel file is opened? i.e. the buttons are blue to start with, and i don't have to push a macro button to make them blue...
0
 
shaolinfunkAuthor Commented:
Also, the debugger highlighted "CommandButton1" with a "method or data member not found" error...how do I find out what the name of the grey button is?
0
 
hiteshgoldeneyeCommented:
put the code in the workbook open event
Private Sub Workbook_Open()
Sheet1.CommandButton1.Picture = LoadPicture("C:\hithtml\Prairie Wind.bmp")

End Sub
0
 
hiteshgoldeneyeCommented:
The name of the button can be found by right clicking the button and clicking on properties
0
 
shaolinfunkAuthor Commented:
right clicking the button and clicking on properties is not possible from witihin excel....there's no properties option...
0
 
shaolinfunkAuthor Commented:
also, after editing the macro from within excel i cannot find the open workbook event...where is that?  thanks for your help..
0
 
hiteshgoldeneyeCommented:
double click Thisworkbook in the left pane, then on your right pane in the left combobox select workbook, in the right combobox select open.Then type my code
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now