Font in Userform

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hello,
I would like to change the font in mutliple userforms that contain a variety
of items such as frames, textboxes, etc. Decided I don't like the way the
userforms look and would like to try other fonts. Is there code that can be
written to change the font in userforms? Doesn't seem possible to me.

Thanks,

Bill
 
Bill, if you put this in the userform's module, it will change all the
fonts when the form is displayed. However, it doesn't "stick", so when
you view the form in design mode, it'll look as it did originally.
Maybe someone else has an idea on making it stick.
James

Private Sub UserForm_Initialize()
Dim e As Integer
For e = 0 To Me.Controls.Count - 1
With Me.Controls(e).Font
.Bold = True
.Name = "Times New Roman"
.Size = 12
End With
Next e
End Sub
 
Sub Changefont()
Dim fnt As Font
Dim ctrl As Object
Dim frm As Object
Set frm = ThisWorkbook.VBProject.VBComponents("Userform1")
For Each ctrl In frm.Designer.Controls
On Error Resume Next
ctrl.Font.Name = "Arial"
On Error GoTo 0
Next

End Sub
 
Tom, Is this standard VBA, put in a standard module? I get error
"Programmatic access to form not trusted" or something like that.
Never seen that one before! If I reset and run again, I get error
"Method VB Object of _Workbook failed".
James
 
go to tools/macro/secuity, click trusted publishers and select trust
access to visual basic projects.
 
Back
Top