fjfhgdwfn 发表于 2005-10-27 17:39:00

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"&nbsp;&nbsp;&nbsp; '修改路径<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; s = Dir(Path &amp; "\" &amp; FileName)<BR>&nbsp; <BR>&nbsp; point1(0) = 70 '打印范围<BR>&nbsp; point1(1) = 70<BR>&nbsp; point2(0) = 4130<BR>&nbsp; point2(1) = 2900</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; While s &lt;&gt; ""<BR>&nbsp;&nbsp;&nbsp;&nbsp; dwgname = Path &amp; "\" &amp; s<BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.Application.Documents.Open dwgname</P>
<P>&nbsp;If Not ThisDrawing.ModelSpace.Layout.StyleSheet = "acad.ctb" Then ThisDrawing.ModelSpace.Layout.StyleSheet = "acad.ctb" ' 修改打印样式表<BR>&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.SetWindowToPlot point1, point2<BR>&nbsp;&nbsp; <BR>&nbsp; ThisDrawing.ModelSpace.Layout.GetWindowToPlot point1, point2<BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.PlotType = acWindow<BR>&nbsp;<BR>&nbsp;ThisDrawing.ModelSpace.Layout.UseStandardScale = 0.001 '修改比例<BR>&nbsp; ThisDrawing.ModelSpace.Layout.PlotWithPlotStyles = True<BR>&nbsp; <BR>&nbsp; If Not ThisDrawing.ModelSpace.Layout.ConfigName = "HP LaserJet 5000LE" Then ThisDrawing.ModelSpace.Layout.ConfigName = "HP LaserJet 5000LE" ' 修改打印机<BR>&nbsp; If Not ThisDrawing.ModelSpace.Layout.CanonicalMediaName = "A3" Then ThisDrawing.ModelSpace.Layout.CanonicalMediaName = "A3" ' 修改图幅<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.Plot.NumberOfCopies = 1<BR>&nbsp; ThisDrawing.ModelSpace.Layout.PlotRotation = ac90degrees <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.PaperUnits = acMillimeters<BR>&nbsp;&nbsp; ThisDrawing.Plot.PlotToDevice<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = Dir<BR>&nbsp;&nbsp;&nbsp;&nbsp; Wend<BR>&nbsp; <BR>End Sub<BR></P>

lafare 发表于 2005-10-30 20:54:00

如果在DWG文件中包含若干图形,这个程序恐怕就不应用了!

fjfhgdwfn 发表于 2005-10-31 10:01:00

<P>如果有规律,改下就行了吧</P>
<P>自己改了下重上传</P>
页: [1]
查看完整版本: VBA批打印程序(打印同一目录下的DWG)