开发者

Capture edit mode through checking the standard tool bar

开发者 https://www.devze.com 2022-12-24 00:30 出处:网络
I\'m using this code to check if the standard toolbar is deactivated in the edit mode. CommandBarControl oNewMenu = Application.CommandBars(\"Worksheet Menu Bar\").FindControl(1, 18, 1, True, True)

I'm using this code to check if the standard toolbar is deactivated in the edit mode.

CommandBarControl oNewMenu = Application.CommandBars("Worksheet Menu Bar").FindControl(1, 18, 1, True, True)

If (IsNull(oNewMenu)) Then

    MsgBox "Edit mode enabled"

End开发者_如何学编程 If

The FindControl function raise an error. Is there any conflict in the parameters?


I'm confused because the first statement will never compile. Moreover when evaluating existence of an object you should use 'Is Nothing' instead of 'IsNull'. Anyway try this:


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
0

精彩评论

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

关注公众号