1

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?

Community
  • 1
  • 1
Srimal
  • 11
  • 1

1 Answers1

0

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
  • in the following line what exactly oControl.Enable mean.Shoudn't the labels "enable" and "disable" be interchanged. MsgBox "Edit mode " & IIf(oControl.Enabled, "enabled", "disabled"), vbInformation . Thank you... – Srimal Mar 24 '10 at 04:49