Change Caption of Button

G

Guest

Hi,

I just added a button to one of my worksheets this way:

ActiveSheet.Buttons.Add(100, 300, 180, 15)

Now I would like to change the caption of the button, but don't know how to
do it. Help and MSDN-Reference don't cover this object or I cannot find it.

I can add an event to my buttons, but cannot change the caption...

ActiveSheet.Shapes(3).OnAction = "SwitchTo_"
ActiveSheet.Shapes(3).Name = "Caption" ' doesn't work

Any suggestions?

Many thanks
Alex
 
J

Jake Marx

Hi Alexander,

Here's one way - name the button as you create it:

Sheet1.Buttons.Add(100, 300, 180, 15).Name = "btnTest"
Sheet1.Buttons("btnTest").Caption = "Test"

If you want to access the button from the Shapes collection, I think you'll
have to use this method:

ActiveSheet.Shapes(3).OLEFormat.Object.Caption = "Test"

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
G

Guest

Try this:

Sub test()
With ActiveSheet.Buttons.Add(100, 300, 180, 15)
.Caption = "whatever"
End With
End Sub
 

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