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