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
xdhmoore
  • 8,935
  • 11
  • 47
  • 90

1 Answers1

2

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
  • 32,673
  • 4
  • 52
  • 73