Hi
I have this toolbar which comes up as an Add-In to Excel. It includes commands to insert rows, delete rows and change fill colour.
* Does any one know how to add the command for fonts into the Add-In? Also is there a way to specify the width of the command?
ThisWorkBook
Module
I have this toolbar which comes up as an Add-In to Excel. It includes commands to insert rows, delete rows and change fill colour.
* Does any one know how to add the command for fonts into the Add-In? Also is there a way to specify the width of the command?
ThisWorkBook
Code:
Option Explicit
Private Sub Workbook_Open()
Call My_Toolbar_Create
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call My_Toolbar_Delete
End Sub
Private Sub Workbook_Activate()
On Error Resume Next
Application.CommandBars(My_Toolbar_Name).Visible = True
On Error GoTo 0
End Sub
Private Sub Workbook_Deactivate()
On Error Resume Next
Application.CommandBars(My_Toolbar_Name).Visible = False
On Error GoTo 0
End Sub
Module
Code:
Option Explicit
Public Const My_Toolbar_Name As String = "Toolbar"
Sub My_Toolbar_Delete()
On Error Resume Next
Application.CommandBars(My_Toolbar_Name).Delete
On Error GoTo 0
End Sub
Sub My_Toolbar_Create()
Dim c_b As CommandBar, c_b_b As CommandBarButton
My_Toolbar_Delete
Set c_b = Application.CommandBars.Add(My_Toolbar_Name, msoBarTop, False, True)
With c_b
Set c_b_b = c_b.Controls.Add(msoControlButton, , , , True)
With c_b_b
.OnAction = "'" & ThisWorkbook.Name & "'!Format_Insert_Rows"
.TooltipText = "Insert Rows"
.Style = msoButtonIcon
.FaceId = 296
.BeginGroup = False
End With
Set c_b_b = c_b.Controls.Add(msoControlButton, , , , True)
With c_b_b
.OnAction = "'" & ThisWorkbook.Name & "'!Format_Delete"
.TooltipText = "Delete Rows"
.Style = msoButtonIcon: .FaceId = 293
.BeginGroup = False
End With
Set c_b_b = c_b.Controls.Add(msoControlButton, , , , True)
With c_b_b
.OnAction = "'" & ThisWorkbook.Name & "'!Format_Colour_Fill"
.TooltipText = "Colour Fill"
.Style = msoButtonIcon: .FaceId = 1691
.BeginGroup = True
End With
Set c_b_b = Nothing: .Visible = True: .Left = 0: .Top = 200: End With
Set c_b = Nothing
End Sub
Sub Format_Insert_Rows()
Selection.EntireRow.Insert
End Sub
Sub Format_Delete()
Selection.EntireRow.Delete
End Sub
Sub Format_Colour_Fill()
Application.Dialogs(xlDialogPatterns).Show
End Sub