Udostępnij za pośrednictwem


Command Interface

Represents a command in the environment.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
<GuidAttribute("5FE10FB0-91A1-4E55-BAAA-ECCAE5CCEB94")> _
Public Interface Command
'Usage
Dim instance As Command
[GuidAttribute("5FE10FB0-91A1-4E55-BAAA-ECCAE5CCEB94")]
public interface Command
[GuidAttribute(L"5FE10FB0-91A1-4E55-BAAA-ECCAE5CCEB94")]
public interface class Command
public interface Command

Remarks

Reference this object by using Item.

You can reference this object a number of ways, such as by using the canonical name or the GUID ID. The easiest way to invoke most commands is by using ExecuteCommand. You can use Raise for the rare instances when you must invoke a command without a name.

Examples

' Macro code.
Sub CommandExample()
  ' Creates a text document listing all command names.
  Dim Cmd As Command
  Dim Doc As Document
  Dim TxtDoc As TextDocument

  ' Create a new text document.
  DTE.ItemOperations.NewFile ("General\Text File")
  Set Doc = ActiveDocument
  Set TxtDoc = Doc.Object("TextDocument")
  For Each Cmd In Commands
  If (Cmd.Name <> "") Then
    TxtDoc.Selection.Text = Cmd.Name & vbLF
    TxtDoc.Selection.Collapse
  End If
  Next
End Sub

See Also

Reference

Command Members

EnvDTE Namespace