VBA Font Object Query
Hi Robert,
Try the following code which endeavours to adapt some code by John
Walkenbach to meet your needs:
'=================
Public Sub Tester()
Dim FontList As CommandBarComboBox
Dim i As Long
Dim tempbar As CommandBar
Dim arr As Variant
On Error Resume Next
Set FontList = Application.CommandBars("Formatting"). _
FindControl(ID:=1728)
If FontList Is Nothing Then
Set tempbar = Application.CommandBars.Add
Set FontList = tempbar.Controls.Add(ID:=1728)
End If
ReDim arr(1 To FontList.ListCount)
On Error GoTo 0
For i = 1 To FontList.ListCount - 1
arr(i) = FontList.List(i)
Next i
' Delete temp CommandBar if it exists
On Error Resume Next
tempbar.Delete
End Sub
'<<=================
---
Regards,
Norman
"Robert Mulroney" '''' wrote in message
...
I need to make an array of font objects, I don't even seem to be able to
make even one. Why doesn't this code work:
Public Sub x()
Dim f as Font
Set f = New Font
f.Name = "Arial"
End Sub
I'm getting an error on the 2nd line, "Invalid use of New keyword". Any
thoughts?
- Rm
|