新编了一个程序如下:
Private Sub cmdOk_Click() Dim i As Integer Dim ii As Integer Dim zz As Integer Dim drn As String Dim drn1 As String Dim ptmin As Variant, ptmax As Variant Dim ent As AcadEntity Dim x As Integer If lstFile.ListCount = 0 Then MsgBox "请添加所要操作的图形!" Exit Sub End If frmMain.hide For i = 0 To lstFile.ListCount - 1 drn1 = lstFile.List(i) Application.Documents.Open drn1 For Each ent In ThisDrawing.PaperSpace If TypeOf ent Is AcadBlockReference Then If StrComp(ent.Name, "TITLE", vbTextCompare) <> 0 Then ent.GetBoundingBox ptmin, ptmax Exit For End If End If Next ent ReDim Preserve ptmin(0 To 1) ReDim Preserve ptmax(0 To 1) Dim currentPlot As AcadPlot Set currentPlot = ThisDrawing.Plot ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax ThisDrawing.ActiveLayout.PlotType = acWindow If ComboBox1.Text = "ScaleToFit" Then ThisDrawing.ActiveLayout.StandardScale = acScaleToFit MsgBox TextBox2.Text ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text Else ThisDrawing.ActiveLayout.StandardScale = ac1_1 ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text End If currentPlot.PlotToDevice TextBox1.Text Application.ActiveDocument.Close True, drn1 Next i
End Sub
程序运行到ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text处时出现错误,提示为INVALID INPUT.而TextBox2.Text的内容是笔表ctb文件的完整路径。删去此行时,程序运行完毕,但无笔表设置。请问为什么? |