views:

46

answers:

1

Excel VBA:
I am trying to get to some activex option buttons through the OLEObjects object, but I am finding that even though I change the value of (Name) in the property window for the object, it still requires the "OptionButton1" default name as a key.

I know that some of the objects in Excel VBA have a code name and another name which is also the one used for the key to get to it from OLEObjects, but I don't know how I can change this "other" name.

I am passing in my object name as a parameter (basically) to a function, so I can't just do :

ActiveSheet.optMyNewName.Value

or whatever. I need to be able to do this:

ActiveSheet.OLEObjects("optMyNewName").Object.Value

but currently only this works:

ActiveSheet.OLEObjects("OptionButton1").Object.Value
+1  A: 

If you pass a string into the OLEObjects collection, it uses the Caption property as the key. Pass the caption as the parameter and it should work.

Dick Kusleika