Window2.CommandBars プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オブジェクトに関連付けられているウィンドウに含まれる Microsoft Office CommandBars コレクションへの参照を WindowObject 取得します。
public:
property System::Object ^ CommandBars { System::Object ^ get(); };
public object CommandBars { get; }
member this.CommandBars : obj
Public ReadOnly Property CommandBars As Object
プロパティ値
実装
例
注: 次の例では、 System.Reflection 名前空間への参照が必要です。
BindingFlags flags = BindingFlags.GetProperty | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance;
// The CommandBars collection returns only one of the objects
// that implements an IDispatch interface.
// To perform checks and allow COM-like calls,
// you must create a wrapper by casting to the ObjectWrapper class.
ObjectWrapper commandBars = (ObjectWrapper)thisApplication.ActiveWindow.<span class="label">CommandBars</span>;
int commandBarsCount = (int)commandBars.InvokeByName(
"Count", // prop
flags,
null, // arguments
null); // Culture
thisXDocument.UI.Alert("There are " + commandBarsCount.ToString() + " Command Bars");
// Either of the following two lines will work
object[] args = new object[] {1};
// object[] args = new object[] {"Standard"};
// This object is outside the wrapper - this gets a .NET object
object commandBarItem = commandBars.InvokeByName(
"Item",
flags,
args, // arguments
null); // Culture
thisXDocument.UI.Alert("Got the 'Standard' command bar");
string commandBarName = (string)commandBarItem.GetType().InvokeMember(
"name",
flags,
null,
commandBarItem,
null);
thisXDocument.UI.Alert(commandBarName);
注釈
CommandBars コレクションは、完全に信頼されているフォームでのみ使用できます。 完全に信頼されていないフォームで使用した場合、CommandBars コレクションは "アクセスが拒否された" というエラーを返します。
重要: このメンバーは、[フォーム オプション] ダイアログ ボックスの [セキュリティと信頼] カテゴリを使用して完全信頼で実行するように構成されたフォーム テンプレートから開かれたフォームによってのみアクセスできます。 このメンバは、直接の呼び出し側の完全な信頼が必要であり、部分的に信頼されたコードでは使用できません。 詳細については、MSDN の「部分信頼コードからのライブラリの使用」を参照してください。