Change both the code name and the shape name of an activex optionbutton control in Excel vba
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 开发者_StackOverflow中文版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
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.
精彩评论