Skip to content

Instantly share code, notes, and snippets.

@dck-jp
Created August 19, 2012 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dck-jp/3390557 to your computer and use it in GitHub Desktop.
Save dck-jp/3390557 to your computer and use it in GitHub Desktop.
Application.CommandBars.Add Test
Attribute VB_Name = "ModuleToolbar"
Option Explicit
Const toolbarName = "Sample"
Sub MakeToolBar()
Dim myBar As CommandBar
Set myBar = Application.CommandBars.Add( _
Name:=toolbarName, Position:=msoBarFloating)
myBar.Visible = True
Dim myButton As CommandBarControl
Set myButton = myBar.Controls.Add(Type:=msoControlButton)
With myButton
.style = msoButtonIconAndCaption
.OnAction = "SampleAction1"
.faceId = 84
.caption = "サンプル1"
End With
Set myButton = myBar.Controls.Add(Type:=msoControlButton)
With myButton
.style = msoButtonCaption
.OnAction = "SampleAction2"
.faceId = 83
.caption = "サンプル2"
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment