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