写成一个调用函数,这样方便使用:
- Function GetFonts(ByRef FontFile As Variant, ByRef BigFontFile As Variant)
- Dim strFontFile(), strBigFontFile() As String
- Dim SearchPath() As String
- Dim a As String
- Dim i As Integer
- Dim x As Integer
- Dim y As Integer
- Dim z As Boolean
- Dim b As String
-
- SearchPath = Split(ThisDrawing.Application.Preferences.Files, ";")
- For i = 0 To UBound(SearchPath)
- z = False
- SearchPath(i) = IIf(Right(SearchPath(i), 1) = "", SearchPath(i), SearchPath(i) & "")
- Do
- If Not z Then
- a = Dir(SearchPath(i) & "*.shx")
- z = True
- Else
- a = Dir
- End If
- If a <> "" Then
- a = SearchPath(i) & a
- Open a For Input As #1
- Line Input #1, b
- Close #1
- If Mid(b, 12, 7) = "bigfont" Then
- x = x + 1
- ReDim Preserve strBigFontFile(x)
- strBigFontFile(x) = a
- ElseIf Mid(b, 12, 7) = "unifont" Then
- y = y + 1
- ReDim Preserve strFontFile(y)
- strFontFile(y) = a
- End If
- Else
- Exit Do
- End If
- Loop
- Next i
- FontFile = strFontFile
- BigFontFile = strBigFontFile
- End Function
- Sub GetShxFont()
- Dim f As Variant
- Dim bf As Variant
- GetFonts f, bf
- Dim i As Integer
- Debug.Print "以下为普通字体:"
- For i = 0 To UBound(f)
- Debug.Print f(i)
- Next
- Debug.Print "以下为大字体:"
- For i = 0 To UBound(bf)
- Debug.Print bf(i)
- Next
- End Sub
|