Changing the Option Button Name (not Caption)

DRANDON

Active Member
Joined
Jun 30, 2006
Messages
268
I am trying to revise a few properties of an Option Button I have on my worksheet. I'm trying this:

Dim shp as shape
Set shp = ActiveSheet.Shapes(Selection.Name)

With shp.OLEFormat.Object
.Object.Caption = "2015"
.Name = "Y2015"
.Enabled = False
End With

All is successful except the Name. I've tried putting ".Object" in front of ".Name" to no avail. It remains what it was. Any ideas. Thank you so much.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You cannot make the name the same as a Cell number, try a different name like "Y_2015".
 
Upvote 0
Using the macro recorder I get two options:

Code:
    ActiveSheet.Shapes("happytime").Name = "happytime"
    Selection.Name = "happytime"

So the .Name should be correct.
 
Upvote 0
This works fine for me for a Forms option button.
Code:
    With shp.OLEFormat.Object
        .Caption = "2015"
        .Name = "Y2015"
        .Enabled = False
    End With
 
Upvote 0
Whats the difference between:

shp.OLEFormat.Object.Name = "Y_2015"

and trying the following

shp.Name = "Y_2015"

I'm not familiar with the OLEFormat object
 
Upvote 0
Thanks Norie, but my option button is an ActiveX button. Maybe that has something to do with it? Why then would Caption and Enabled work fine. hmmm
 
Upvote 0
If it's an ActiveX button why are you using the Shapes collection to refer to it, isn't that kind of indirect.

This code works for me for an ActiveX button.
Code:
Dim opt As OLEObject

    Set opt = ActiveSheet.OLEObjects(1)
    
    opt.Name = "Y2015"
    
    opt.Object.Caption = "2015"
 
Upvote 0
Thanks Norie. I tried this:
Set opt = ActiveSheet.OLEObjects("Y2013")
opt.Name = "Y2015"
opt.Object.Caption = "2015"
opt.Enabled = False
and yet still everything worked well EXCEPT the name change. ("Y2013" is the current name before i attempt to change it). I also tried different order.
 
Upvote 0
What exactly do you mean by not working?
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top