我已经将Backgroundplot变量设为0。源程序如下:
Private Sub CommandButton1_Click() Err.Clear On Error Resume Next Dim objlayer, shutdownobjlayer, layerObj As AcadLayer Dim layername, shutdownlayername, a As String
For i = 0 To Listlayer2.ListCount - 1 ' 把list2中的层都关掉 layername = Listlayer2.List(i) 'Set objlayer = ThisDrawing.Layers.Item(layername) For j = 0 To Listlayer2.ListCount - 1 shutdownlayername = Listlayer2.List(j) Set shutdownobjlayer = ThisDrawing.Layers.Item(shutdownlayername) shutdownobjlayer.LayerOn = False If shutdownlayername = layername Then shutdownobjlayer.LayerOn = True '把要打印的层打开 a = layername End If Next j ThisDrawing.Application.Documents.ModelSpace.PlotType = acWindow Set layerObj = ThisDrawing.Layers.Item(a)
ThisDrawing.ActiveLayer = layerObj ThisDrawing.Plot.PlotToDevice '打印 If MsgBox("现在正在打印的图层是" + a _ + ",先不要按确定,等打完了再按." + "如果发现打印格式不对,就按取消", _ vbOKCancel + vbInformation) = vbCancel Then Exit For
Next i
End Sub
恳请大大蒙帮忙。 |