Dim objDbx As AxDbDocument
If Left(Version, 2) = "15" Then Set objDbx = CreateObject("ObjectDBX.AxDbDocument.1") ElseIf Left(Version, 2) = "16" Then Set objDbx = CreateObject("ObjectDBX.AxDbDocument.16") End If
Opendatabase
'打开数据库,遍历图纸,得到要打开的图纸路径
Dim i As Integer Dim SheetPath As String '图纸详细路径变量 Dim adoRs As New Recordset adoRs.Open "SheetList", adoCon, adOpenDynamic, adLockOptimistic adoRs.MoveFirst For i = 0 To adoRs.RecordCount - 1 SSheetName = adoRs.Fields("SheetName") '图纸详细路径 objDbx.Open SSheetName Dim txtStyleObj As AcadTextStyle ' 添加文字样式到文字样式集合中 Set txtStyleObj = objDbx.TextStyles.Add("仿宋_GB2312") txtStyleObj.SetFont "仿宋_GB2312", False, False, 1, 0 ThisDrawing.ActiveTextStyle = txtStyleObj objDbx.SaveAs SheetPath Next i adoRs.Close
以上代码实现了在不打开图纸的情况下,为每张图纸添加了“仿宋_GB2312”,但并没有实现图纸的初始默认字体为“仿宋_GB2312”。
我曾尝试objDbx.ActiveTextStyle = txtStyleObj这条语句,但失败了。请问如何才能设置为图纸的当前字体为我所添加的字体?? |