VBA批打印程序(打印同一目录下的DWG)
<P>不知道哪位兄弟给改进下,如果我用了CLOSE,怎么会出错啊!望高手改进下!初学。<BR>Sub wj()<BR>Dim s As String<BR>Dim Path As String, FileName As String<BR>Dim dwgname As String<BR>Dim point1(0 To 1) As Double, point2(0 To 1) As Double<BR>FileName = "*.dwg"<BR>Path = "C:\123" '修改路径<BR> <BR> s = Dir(Path & "\" & FileName)<BR> <BR> point1(0) = 70 '打印范围<BR> point1(1) = 70<BR> point2(0) = 4130<BR> point2(1) = 2900</P><P> While s <> ""<BR> dwgname = Path & "\" & s<BR> <BR> ThisDrawing.Application.Documents.Open dwgname</P>
<P> If Not ThisDrawing.ModelSpace.Layout.StyleSheet = "acad.ctb" Then ThisDrawing.ModelSpace.Layout.StyleSheet = "acad.ctb" ' 修改打印样式表<BR> ThisDrawing.ModelSpace.Layout.SetWindowToPlot point1, point2<BR> <BR> ThisDrawing.ModelSpace.Layout.GetWindowToPlot point1, point2<BR> <BR> ThisDrawing.ModelSpace.Layout.PlotType = acWindow<BR> <BR> ThisDrawing.ModelSpace.Layout.UseStandardScale = 0.001 '修改比例<BR> ThisDrawing.ModelSpace.Layout.PlotWithPlotStyles = True<BR> <BR> If Not ThisDrawing.ModelSpace.Layout.ConfigName = "HP LaserJet 5000LE" Then ThisDrawing.ModelSpace.Layout.ConfigName = "HP LaserJet 5000LE" ' 修改打印机<BR> If Not ThisDrawing.ModelSpace.Layout.CanonicalMediaName = "A3" Then ThisDrawing.ModelSpace.Layout.CanonicalMediaName = "A3" ' 修改图幅<BR> <BR> <BR> ThisDrawing.Plot.NumberOfCopies = 1<BR> ThisDrawing.ModelSpace.Layout.PlotRotation = ac90degrees <BR> ThisDrawing.ModelSpace.Layout.PaperUnits = acMillimeters<BR> ThisDrawing.Plot.PlotToDevice<BR> <BR> s = Dir<BR> Wend<BR> <BR>End Sub<BR></P> 如果在DWG文件中包含若干图形,这个程序恐怕就不应用了! <P>如果有规律,改下就行了吧</P>
<P>自己改了下重上传</P>
页:
[1]