首页 > 解决方案 > 升级到 Excel 16 时单选按钮参考上的错误消息

问题描述

大家好,感谢您的时间和支持,

我的公司刚刚将我们的 excel 升级到 Excel 365,现在我有一些单选按钮的工作表将无法工作并产生以下错误:

在此处输入图像描述

它以前工作得很好,错误发生在下面的第一行代码,三个表单控件单选按钮在一个组框中,任何提示或建议将不胜感激。

    Sub Approved_Click()

    If ActiveSheet.Shapes("Yearly").ControlFormat.Value = 1 Then

    ActiveSheet.Shapes("Scroll Bar 10").Visible = False

标签: excelvba

解决方案


由于您没有回答我关于控件类型的问题,请尝试下一个代码:

Sub testOptionButtons()
 Dim sh As Worksheet
 Set sh = ActiveSheet
 'for a Form Type use this code:
 Debug.Print sh.Shapes("Yearly").ControlFormat.value
  'for a ActiveX Type use this code:
 Debug.Print sh.Shapes("Yearly").OLEFormat.Object.Object.value
End Sub

或者,如果您不确定它们的类型,请同时测试它们。


推荐阅读