- 积分
- 500
- 明经币
- 个
- 注册时间
- 2004-5-10
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2005-3-9 16:54:00
|
显示全部楼层
新增功能:将字体支持文件拷贝至指定文件夹。
Option Explicit Function getfontfile(fontfilepath As String) As String '返回图形fontfile字体支持文件目录下的字体支持文件 Dim fontfilepaths() As String Dim i, j, m, n As Integer Do j = InStr(i + 1, fontfilepath, "\") If j = 0 Then n = Len(fontfilepath) getfontfile = Right(fontfilepath, n - i) Exit Do Else ReDim Preserve fontfilepaths(m) fontfilepaths(m) = Mid(fontfilepath, i + 1, j - i - 1) i = j m = m + 1 End If Loop End Function Sub getfontfilepath() Dim supportfilepath As String Dim supportfilepaths() As String Dim i, j, m, n As Integer '返回图形支持文件目录 supportfilepath = ThisDrawing.Application.preferences.Files.supportpath Do j = InStr(i + 1, supportfilepath, ";") If j = 0 Then n = Len(supportfilepath) ReDim Preserve supportfilepaths(m) supportfilepaths(m) = Right(supportfilepath, n - i) Exit Do Else ReDim Preserve supportfilepaths(m) supportfilepaths(m) = Mid(supportfilepath, i + 1, j - i - 1) i = j m = m + 1 End If Loop Dim element As AcadTextStyle Dim fontfilepath As String Dim fontfile As String Dim fontfiles() As String Dim bigfontfilepath As String Dim bigfontfile As String Dim bigfontfiles() As String Dim k, l As Integer '返回图形fontfile字体支持文件目录 n = 0 For Each element In ThisDrawing.TextStyles fontfile = element.fontfile For i = 0 To m fontfilepath = supportfilepaths(i) + "\" + fontfile fontfilepath = Dir(fontfilepath) If fontfilepath <> "" Then If k = 0 Then ReDim Preserve fontfiles(k) fontfiles(k) = supportfilepaths(i) + "\" + fontfile k = k + 1 Else ReDim Preserve fontfiles(k) fontfiles(k) = supportfilepaths(i) + "\" + fontfile For j = 0 To k - 1 If LCase(fontfiles(k)) = LCase(fontfiles(j)) Then n = n + 1 End If Next j If n = 0 Then k = k + 1 Else n = 0 End If End If Exit For End If Next i Next '返回图形bigfontfile字体支持文件目录 For Each element In ThisDrawing.TextStyles bigfontfile = element.bigfontfile If bigfontfile <> "" Then For i = 0 To m bigfontfilepath = supportfilepaths(i) + "\" + bigfontfile bigfontfilepath = Dir(bigfontfilepath) If bigfontfilepath <> "" Then If l = 0 Then ReDim Preserve bigfontfiles(k) bigfontfiles(k) = supportfilepaths(i) + "\" + bigfontfile l = l + 1 Else ReDim Preserve bigfontfiles(l) bigfontfiles(l) = supportfilepaths(i) + "\" + bigfontfile For j = 0 To l - 1 If LCase(bigfontfiles(l)) = LCase(bigfontfiles(j)) Then n = n + 1 End If Next j If n = 0 Then l = l + 1 Else n = 0 End If End If Exit For End If Next i End If Next '显示图形中fontfile和bigfontfile字体支持文件目录 ThisDrawing.Utility.Prompt vbCrLf & "fontfile字体支持文件:" & vbCrLf For i = 0 To k - 1 ThisDrawing.Utility.Prompt fontfiles(i) & vbCrLf Next i ThisDrawing.Utility.Prompt "bigfontfile字体支持文件:" For i = 0 To l - 1 ThisDrawing.Utility.Prompt bigfontfiles(i) & vbCrLf Next i '选择是否将字体支持文件拷贝至指定文件夹 Dim kwordList As String Dim destpath, destpath0 As String On Error Resume Next kwordList = "Yes No" ThisDrawing.Utility.InitializeUserInput 1, kwordList Dim returnString As String returnString = ThisDrawing.Utility.GetKeyword("是否将字体支持文件拷贝至指定文件夹[Yes/No]:") If returnString = "Yes" Then destpath = InputBox("请输入目标文件夹!", "字体文件", ThisDrawing.Path) destpath0 = destpath destpath = Dir(destpath, vbDirectory) If destpath <> "" Then For i = 0 To k - 1 FileCopy fontfiles(i), destpath0 & "\" & getfontfile(fontfiles(i)) Next i For i = 0 To l - 1 FileCopy bigfontfiles(i), destpath0 & "\" & getfontfile(bigfontfiles(i)) Next i ThisDrawing.Utility.Prompt vbCrLf & "图形字体支持文件已拷贝至指定文件夹" & vbCrLf Else MsgBox "请输入正确的目标文件夹!" Exit Sub End If Else Exit Sub End If End Sub |
|