Change Font Bug in UserForm?

Anonymous
2016-05-20T13:37:40+00:00

It appears an issue occurs when changing the font in a UserForm Label through VBA while it is active or through the UserForm_Initialize() Event.

When using the below code:

Private Sub CommandButton1_Click()

    With Me

        .Label1.BackColor = RGB(0, 204, 0) 

        .Label1.Caption = "û"

        .Label1.Font.Size = 16

        .Label1.ForeColor = RGB(255, 255, 255) 'white

        '.Label1.Font.Name = "Arial"

        .Label1.Font.Name = "WingDings"

    End With

End Sub

Private Sub UserForm_Initialize()

   With Me

        .Label1.BackColor = RGB(0, 204, 0) 

        .Label1.Caption = "û"

        .Label1.Font.Size = 16

        .Label1.ForeColor = RGB(255, 255, 255) 'white

        '.Label1.Font.Name = "Arial"

        .Label1.Font.Name = "WingDings"

    End With

End Sub

If UserForm Label1 is set originally to Tahoma the VBA code does not perform as expected.

Here is a discussion on the Mr. Excel Forum that further documents the UserForm behavior:

Mr Excel Discussion

While I found a workaround that will coerce the result (Uncomment this line of code:   '.Label1.Font.Name = "Arial"). I would think it should work as intended with the one line of code...  Unless, I'm missing something.

Can someone please provide feedback on this issue?

Thank you.

This issue occurred in Excel 2010 (Version: 14.0.7165.5000) 32- Bit, Windows 7 Enterprise 64-Bit Service Pack 1

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Anonymous
    2017-04-18T08:11:21+00:00

    If you add line to set charset correctly then it works as expected.

    Private Sub UserForm_Initialize()

       With Me

            .Label1.BackColor = RGB(0, 204, 0)

            .Label1.Font.Size = 16

            .Label1.Font.Name = "WingDings"

            .Label1.Font.Charset = 2

            .Label1.Caption = "û"

            .Label1.ForeColor = RGB(255, 255, 255) 'white

        End With

    End Sub

    2 people found this answer helpful.
    0 comments No comments