This documentation is archived and is not being maintained.

Commands Interface

Contains all of the commands, in the form of Command objects, in the environment.

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

public interface Commands : IEnumerable

Imports Microsoft.VisualStudio.CommandBars
Sub CommandsExample()
   ' Before running, you must add a reference to the Office 
   ' typelib to gain access to the CommandBar object.
   Dim cmds As Commands
   Dim cmdobj As Command
   Dim customin, customout As Object
   Dim cmdbarobj As CommandBar
   Dim colAddins As AddIns

   ' Set references.
   colAddins = DTE.AddIns()
   cmds = DTE.Commands
   cmdobj = cmds.Item("File.NewFile")

   ' Execute the File.NewFile command.
   cmds.Raise(cmdobj.Guid, cmdobj.ID, customin, customout)

   ' Create a toolbar and add the File.NewFile command to it.
   cmdobj = cmds.Item("File.NewFile")
   cmdbarobj = cmds.AddCommandBar("Mycmdbar", _
   ' Show the command bar and its button.
   cmdbarobj.Visible = True
End Sub