ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create new commandbar with call procedure (https://www.excelbanter.com/excel-programming/278065-create-new-commandbar-call-procedure.html)

Tonmai

Create new commandbar with call procedure
 
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.

J.E. McGimpsey

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.



All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com