"Change the font face" command in Excel, as an Add-In

Formula11

Active Member
Joined
Mar 1, 2005
Messages
439
Office Version
  1. 365
Platform
  1. Windows
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
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
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try

Code:
Application.Dialogs(xlDialogFontProperties).Show

Hope this helps!
 
Upvote 0
Thanks but I was looking for the command where you can see the font name end edit it manually by typing, just as in Excel on the Home tab.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,438
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top