PDA

View Full Version : List Available Fonts in Access VBA



AppBuilder
03-19-2008, 10:17 AM
I need to get a list of fonts available on the system and use it in Access VBA. I think something like the code below should work, but apparently either I'm not getting the right dll or I'm not using it correctly. Can anyone help?

Thanks very much!

Public Sub ListAllFonts()

'Using Acess 2003 VBA
'Added the following using Tools>References: System, System.Drawing.dll
'The Dim statements return an error of "User defined type not defined"

Dim fontCollection As New System.Drawing.Text.InstalledFontCollection
Dim fontFamily As System.Drawing.Text.FontFamily

For Each fontFamily In fontCollection
Debug.Print fontFamily.Name
Next fontFamily

Set fontFamily = Nothing
Set fontCollection = Nothing

Exit Sub

End Sub