Programmatically change a button caption

Q

quartz

I have an ActiveX button control (entered from the "Control Toolbox") on a
spreadsheet. I want to programmatically change the caption on the face of the
button. The macro recorder does not work.

Could someone please correct my code (below) or provide other code that
functions? FYI, my code so far:

Dim ctrlX As OLEObject
Set ctrlX = ThisWorkbook.ActiveSheet.OLEObjects("CommandButton2")
ctrlX.Caption = "Click to Enter Date" <<< ERROR HERE!

Thanks much in advance.
 
T

Tom Ogilvy

Dim ctrlX As OLEObject
Set ctrlX = ThisWorkbook.ActiveSheet.OLEObjects("CommandButton2")
ctrlX.Object.Caption = "Click to Enter Date"
 
J

Jim Thomlinson

It is a lot easier than that...

sheet1.commandbutton1.caption = "Click to Enter Date"

You will need to modify this for the sheet and button names, but otherwise
is should be good to go...

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top