Hello everyone
I have a code that lists all the fonts installed and I tried to adopt the code to change the font of the cells in column B but it throws error (Unable to seet the name property of the Font class)
Sub Test()
Dim oWord As Object, i As Long
On Error GoTo Error_Handler
Set oWord = CreateObject("Word.Application")
For i = 1 To oWord.FontNames.Count
Cells(i + 1, 2).Font.Name = CStr(oWord.FontNames(i))
Next i
Error_Handler_Exit:
On Error Resume Next
oWord.Quit
Set oWord = Nothing
Exit Sub
Error_Handler:
MsgBox "The Following Error Has Occured." & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: EnumerateFonts" & vbCrLf & _
"Error Description: " & Err.Description, _
vbCritical, "An Error Has Occured!"
Resume Error_Handler_Exit
End Sub
Sub ListFontNames()
Dim FontList
Dim i As Long
Set FontList = Application.CommandBars("Formatting").FindControl(ID:=1728)
For i = 1 To FontList.ListCount
Cells(i, 1) = FontList.List(i)
Cells(i, 1).Font.Name = FontList.List(i)
If i > 5000 Then Exit For
Next i
End Sub