Freigeben über


Window2.CommandBars Eigenschaft

Definition

Ruft einen Verweis auf die Microsoft Office CommandBars-Auflistung ab, die in dem Fenster enthalten ist, das dem WindowObject -Objekt zugeordnet ist.

public:
 property System::Object ^ CommandBars { System::Object ^ get(); };
public object CommandBars { get; }
member this.CommandBars : obj
Public ReadOnly Property CommandBars As Object

Eigenschaftswert

Implementiert

Beispiele

Hinweis: Im folgenden Beispiel ist ein Verweis auf den System.Reflection-Namespace erforderlich.

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);

Hinweise

Die CommandBars-Auflistung kann nur von vollständig vertrauenswürdigen Formularen verwendet werden. Wenn sie von einem Formular verwendet wird, das nicht vollständig vertrauenswürdig ist, gibt die CommandBars-Auflistung den Fehler "Berechtigung verweigert" zurück.

Gilt für: