Is there a way to add a toolbar button that executes a command (built-in or
otherwise) from a macro?
Add toolbar: DTE.CommandBars.Add
Add button: toolbar.Controls.Add(MsoButtonStyle.msoButtonIcon)
I have been unable to figure out how to attach a command to the button. It
may only be possible from Addins, but hoping not.
"Ed Dore [MSFT]" - 05 Nov 2004 00:02 GMT
There sure is. Try doing something like the following:
Sub Hello()
System.Windows.Forms.MessageBox.Show("Hello")
End Sub
Sub SetupHelloBtn()
Dim cmd As Command =
DTE.Commands.Item("Macros.MyMacros.Module1.Hello")
Dim toolbar As CommandBar =
DTE.Commands.AddCommandBar("HelloToolbar",
vsCommandBarType.vsCommandBarTypeToolbar)
Dim helloBtn As CommandBarButton = cmd.AddControl(toolbar)
helloBtn.Style = MsoButtonStyle.msoButtonCaption
helloBtn.Caption = "Hello"
toolbar.Visible = True
End Sub
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.