Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Commands.RemoveCommandBar Method

Removes a command bar that was created with the AddCommandBar method.

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

void RemoveCommandBar (
	[InAttribute] Object CommandBar
void RemoveCommandBar (
	/** @attribute InAttribute() */ Object CommandBar
function RemoveCommandBar (
	CommandBar : Object



Required. The Microsoft.VisualStudio.CommandBars.CommandBar object to remove.

RemoveCommandBar fails if the command bar is intrinsic (built-in) to the environment.

The Microsoft.VisualStudio.CommandBars.CommandBar object is a member of the Microsoft Office object model.

' Macro code.
Imports Microsoft.VisualStudio.CommandBars
Sub RemoveCommandBarExample()
   ' Before running, you must add a reference to the Office 
   ' typelib to gain access to the CommandBar object. Also, for this 
   ' example to work correctly, there should be an add-in available 
   ' in the Visual Studio environment.
   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")

   ' Create a toolbar and add the File.NewFile command to it.
   cmdbarobj = cmds.AddCommandBar("Mycmdbar", _
   MsgBox("Commandbar name: " & cmdbarobj.Name)
   cmds.AddNamedCommand(colAddins.Item(1), "MyCommand", _
   "Button Text", "Some tooltip", True)
End Sub

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.