我正在使用此代码检查标准工具栏是否在编辑模式下停用。
CommandBarControl oNewMenu = Application.CommandBars("Worksheet Menu Bar").FindControl(1, 18, 1, True, True)
If (IsNull(oNewMenu)) Then
MsgBox "Edit mode enabled"
End If
FindControl函数引发错误。参数中是否有冲突?
答案 0 :(得分:0)
我很困惑,因为第一个语句永远不会编译。 此外,在评估对象的存在时,你应该使用'Is Nothing' 而不是'IsNull'。 无论如何试试这个:
Const CTRL_NEW = 2520
Dim oControl As CommandBarControl
Set oControl = CommandBars("Standard").FindControl(Id:=CTRL_NEW)
If Not oControl Is Nothing Then ' Control New is present in Standard bar'
MsgBox "Edit mode " & IIf(oControl.Enabled, "enabled", "disabled"), vbInformation
End If