View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
J.E. McGimpsey J.E. McGimpsey is offline
external usenet poster
 
Posts: 493
Default Create new commandbar with call procedure

one way:

Call this from the Workbook_Open procedure, i.e.:

Private Sub Workbook_Open()
CreateToolBar
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
DestroyToolBar
End Sub

And in a regular module:

Public Sub CreateToolBar()
On Error Resume Next
CommandBars("Tonmai Bar").Delete
On Error GoTo 0
With CommandBars.Add(Name:="Tonmai Bar", _
Position:=msoBarFloating, Temporary:=True)
.Top = 100
.Left = 500
With .Controls.Add(Type:=msoControlButton)
.FaceId = 2950
.OnAction = "MySub"
End With
.Visible = True
End With
End Sub

Public Sub DestroyToolbar()
On Error Resume Next
CommandBars("Tonmai Bar").Delete
On Error GoTo 0
End Sub


In article ,
"Tonmai" wrote:

Hi,
Anybody pls. kindly give me the sample of coding
that create new commandbar with one commandbarbotton while
opening workbook. This commandbarbotton can call one sub
procedure in program.

Thks for any help.
Tonmai K.