本帖最后由 作者 于 2007-7-10 7:35:35 编辑
下面的程序仅能进行第一次循环,第二次就出现问题,请高手指出问题所在 谢谢!!! 思路:前提先要打开一个dwg文件,然后查找并打印文件架中的其他dwg文件 Public Sub my_batchplotdwg() Dim plot As AcadPlot Dim i As Integer Set plot = ThisDrawing.plot filepath = ThisDrawing.Path fileName = ThisDrawing.Name filepathname = filepath & "\" & fileName strFileName = Dir(filepath & "\" & "*.dwg", vbDirectory) i = 0 Do While strFileName <> "" If i > 0 Then Documents.Open (filepath & "\" & strFileName) End If If ThisDrawing.Active = False Then ThisDrawing.Activate End If ' 验证活动空间是模型空间 If ThisDrawing.ActiveSpace = acPaperSpace Then ThisDrawing.MSpace = True ThisDrawing.ActiveSpace = acModelSpace End If '前后台打印设置 ThisDrawing.SetVariable "BACKGROUNDPLOT", 0 ' 设置打印区域的范围和比例、旋转、笔指定 ThisDrawing.ModelSpace.Layout.PlotType = acExtents ThisDrawing.ModelSpace.Layout.PlotRotation = ac0degrees ThisDrawing.ModelSpace.Layout.PaperUnits = acMillimeters '设置打印比例为缩放到图纸大小,并居中打印 ThisDrawing.ModelSpace.Layout.StandardScale = acScaleToFit ThisDrawing.ModelSpace.Layout.CenterPlot = True '设置笔为单色 ThisDrawing.ModelSpace.Layout.StyleSheet = "black.ctb" '选择打印机和纸张 ThisDrawing.ModelSpace.Layout.ConfigName = "TOSHIBA e-STUDIO280Series PCL6" ThisDrawing.ModelSpace.Layout.CanonicalMediaName = "A4" ' 设置打印份数为1 ThisDrawing.plot.NumberOfCopies = 1 ' 设置安静打印 ThisDrawing.plot.QuietErrorMode = True '下一文件 strFileName = Dir '打印 plot.PlotToDevice '关闭文件 ThisDrawing.Close savechanges:=False i = i + 1 Loop '前后台打印设置 ThisDrawing.SetVariable "BACKGROUNDPLOT", 2 End Sub
第一次循环的第一张图可以顺利打印 第二次循环在在执行plottodevice时就会出错 请高手明示 如图:
|