Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
856to860
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
856to860
856to860
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Schriftarten/Fonts auslesen- eigenschaften

Schriftarten/Fonts auslesen- eigenschaften
24.03.2007 19:25:00
lobby007
Hallo Excel VBA-Profis,
ich habe ein Makro das mir die Dateinamen und Schriftartnamen aller Fonts/Schriftartdateien ausliest:
Sub getFontName()
Dim objFS As FileSearch
Dim objSh As Worksheet
Dim strPath As String
Dim intIndex As Integer
On Error GoTo ErrExit
GetMoreSpeed
strPath = "c:\bjprinter" 'Pfad anpassen
Set objFS = Application.FileSearch
With objFS
.NewSearch
.LookIn = strPath
.FileName = "*.ttf"
'.SearchSubFolders = True
If .Execute > 0 Then
Set objSh = ThisWorkbook.Worksheets.Add(after:=ThisWorkbook.Sheets(Sheets.Count))
For intIndex = 1 To .FoundFiles.Count
objSh.Cells(intIndex, 1) = Dir(.FoundFiles(intIndex))
objSh.Cells(intIndex, 2) = TTFontName(.FoundFiles(intIndex))
Next
objSh.Columns.AutoFit
Set objSh = Nothing
End If
End With
ErrExit:
GetMoreSpeed 0
Set objFS = Nothing
End Sub

Private Sub GetMoreSpeed(Optional ByVal Modus As Integer = 1)
Static lngCalc As Long
With Application
If Modus = 1 Then
lngCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
.Calculation = -4135
.Cursor = xlWait
Else
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
.Calculation = IIf(lngCalc  0, lngCalc, -4105)
.Cursor = xlDefault
End If
End With
End Sub
Das hakt zwar manchmal - vor allem bei mehr als 15.000 Fonts aber sonst geht es.
Ich brauche aber jetzt noch die weiteren Felder die bei einem solchen Fonts/Schriftart hinterlegt sind wie z.B. das Copyright etc. am besten alles was noch da ist und dann je Zeile ein Fonts.
Wer weiß Rat?
danke lobby007

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Schriftarten/Fonts auslesen- eigenschaften
24.03.2007 20:17:00
Hubert
Hi,
da geht Excel in die Knie, weil max. 4.000 Formate pro Mappe erlaubt sind.
mfg Hubert
AW: Schriftarten/Fonts auslesen- eigenschaften
24.03.2007 20:31:00
lobby007
Hallo Hubert,
danke,
aber meine 31.000 bekomme ich in 2 mal ausgelesen - jede mit gut 15.000 Fonts. zur Not wären auch 4.000 ok dann muß ich eben teilen - aber wie geht es?
gruß lobby007
AW: Schriftarten/Fonts auslesen- eigenschaften
24.03.2007 20:49:37
Lukas
Hallo Hubert
Leider kann ich das Copyright nicht auslesen, dafür aber vieles anderes.
Declare Function EnumFontFamiliesEx Lib "gdi32" Alias "EnumFontFamiliesExA" (ByVal hdc As Long,  _
lpLogFont As LOGFONT, ByVal lpEnumFontProc As Long, ByVal lParam As Long, ByVal dw As Long) As Long
Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Sub MoveMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any,  _
Source As Any, ByVal Length As Long)
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As  _
Long
Public Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * 32
End Type
Private Type ENUMLOGFONTEX
elfLogFont As LOGFONT
elfFullName As String * 64
elfStyle As String * 32
elfScript As String * 32
End Type
Private Type NEWTEXTMETRIC
tmHeight As Long
tmAscent As Long
tmDescent As Long
tmInternalLeading As Long
tmExternalLeading As Long
tmAveCharWidth As Long
tmMaxCharWidth As Long
tmWeight As Long
tmOverhang As Long
tmDigitizedAspectX As Long
tmDigitizedAspectY As Long
tmFirstChar As Byte
tmLastChar As Byte
tmDefaultChar As Byte
tmBreakChar As Byte
tmItalic As Byte
tmUnderlined As Byte
tmStruckOut As Byte
tmPitchAndFamily As Byte
tmCharSet As Byte
ntmFlags As Long
ntmSizeEM As Long
ntmCellHeight As Long
ntmAveWidth As Long
End Type
Private Type TEXTMETRIC
tmHeight As Long
tmAscent As Long
tmDescent As Long
tmInternalLeading As Long
tmExternalLeading As Long
tmAveCharWidth As Long
tmMaxCharWidth As Long
tmWeight As Long
tmOverhang As Long
tmDigitizedAspectX As Long
tmDigitizedAspectY As Long
tmFirstChar As Byte
tmLastChar As Byte
tmDefaultChar As Byte
tmBreakChar As Byte
tmItalic As Byte
tmUnderlined As Byte
tmStruckOut As Byte
tmPitchAndFamily As Byte
tmCharSet As Byte
End Type
Sub SchriftenAuslesen()
[a2] = "Name"
[a3] = "Name"
[b2] = "Stil"
[b3] = "Stil"
[c2] = "Script"
[c3] = "Script"
[d2] = "Max. Buchstabenbreite"
[d3] = "Max.Buchstabenbreite"
[e2] = "Durchschnittliche Buchstabenbreite"
[e3] = "Durchschnittliche Buchstabenbreite"
Dim Fonts As LOGFONT
Fonts.lfCharSet = 1
Dim RetVal
RetVal = EnumFontFamiliesEx(GetDC(Application.hWnd), Fonts, AddressOf FntEnumProc, 0, 0)
End Sub
Public Function FntEnumProc(ByVal FontDesc As Long, ByVal TMetric As Long, ByVal FontType As  _
Long, ByVal lParam As Long) As Long
Dim LFont As ENUMLOGFONTEX, TM As TEXTMETRIC, NTM As NEWTEXTMETRIC
MoveMemory LFont, ByVal FontDesc, Len(LFont)
If CBool(FontType And TRUETYPE_FONTTYPE) = False Then
MoveMemory TM, ByVal TMetric, Len(TM)
Else
MoveMemory NTM, ByVal TMetric, Len(NTM)
End If
'Font-Informationen ausgeben
[a2].End(xlDown).Offset(1, 0) = Left$(LFont.elfLogFont.lfFaceName, lstrlen(LFont.elfLogFont. _
lfFaceName))
[b2].End(xlDown).Offset(1, 0) = Left$(LFont.elfStyle, lstrlen(LFont.elfStyle))
[c2].End(xlDown).Offset(1, 0) = Left$(LFont.elfScript, lstrlen(LFont.elfScript))
If CBool(FontType And TRUETYPE_FONTTYPE) = False Then
[d2].End(xlDown).Offset(1, 0) = TM.tmMaxCharWidth
[e2].End(xlDown).Offset(1, 0) = TM.tmAveCharWidth
Else
[e2].End(xlDown).Offset(1, 0) = NTM.tmMaxCharWidth
[f2].End(xlDown).Offset(1, 0) = NTM.tmAveCharWidth
End If
FntEnumProc = 1
End Function

Mit dem Lokalfenster kannst du natürlich noch viel mehr auslesen (Standardwerte, ...)
Gruss
Lukas
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige