开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜