开发者

Capture edit mode through checking the standard tool bar

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜