1

このコードを使用して、編集モードで標準ツールバーが無効になっているかどうかを確認しています。

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

If (IsNull(oNewMenu)) Then

    MsgBox "Edit mode enabled"

End If

FindControl 関数はエラーを発生させます。パラメータに競合はありますか?

4

1 に答える 1

0

最初のステートメントがコンパイルされないため、混乱しています。さらに、オブジェクトの存在を評価するときは、'IsNull' の代わりに 'Is Nothing' を使用する必要があります。とにかくこれを試してください:


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
于 2010-03-23T12:01:05.533 に答える