[VBA]关于vba在cad2005中循环打印的问题(有源码)
<P>我想请教 大家一个问题</P><P>我什么这段循环打印的vba程序在2002中可以使用</P>
<P>而在2005中只能打出一张就报错????</P>
<P>很不解,虚心请教</P>
<P>以下是源码:</P>
<P>Sub 批量打印()<BR> Dim x As Integer<BR> Dim i As Integer<BR> Dim length As Double<BR> Dim point1 As Variant, point2 As Variant<BR> Dim point3 As Variant<BR> Dim Message, Title, Default, MyValue<BR> point1 = ThisDrawing.Utility.GetPoint(, "请输入左下角点:")<BR> ReDim Preserve point1(0 To 1) <BR> <BR> point2 = ThisDrawing.Utility.GetPoint(, "请输入右上角点:")<BR> ReDim Preserve point2(0 To 1) <BR> point3 = ThisDrawing.Utility.GetPoint(, "输入第二张图纸左下角点:")<BR> ReDim Preserve point3(0 To 1)<BR> length = point3(0) - point1(0)<BR> <BR>Message = " 输入打印多少张? " </P>
<P>Title = "提醒:" <BR>Default = "1" <BR>x = InputBox(Message, Title, Default)<BR> For i = 1 To x Step 1<BR> <BR> ThisDrawing.ActiveLayout.SetWindowToPlot point1, point2<BR> ThisDrawing.ActiveLayout.GetWindowToPlot point1, point2<BR> ThisDrawing.ActiveLayout.PlotType = acWindow<BR> ThisDrawing.Plot.PlotToDevice '用默认设置打印到打印机<BR> point1(0) = point1(0) + length: point1(1) = point1(1)<BR> point2(0) = point2(0) + length: point2(1) = point2(1)<BR> Next i<BR>End Sub</P> <P>怎么没人顶</P>
<P>希望各位高手解答一下</P> <P>打印份数不需要用For...Next...语句,用这个:</P>
<P>Thisdrawing.Plot.NumberOfCopies = x</P> <P>经测试.在我这没有问题,是可以用的</P> <P>谢谢各位</P>
<P>我在2002中可以正常使用</P>
<P>而在2005中只能打出一张就报错????</P>
<P>不知道为什么</P>
<P>3楼说的可以实现循环吗,试试。。。。</P> <p>看cadVBA 中plottodevice method的帮助,最大的怀疑是 </p><p>你是否打印设置文件有问题?</p><p></p><p class="Heading-2">RetVal = object.PlotToDevice </p><p class="element">Object</p><p class="element-desc"><a href="mk:@MSITStore:D:\Program%20Files\Common%20Files\Autodesk%20Shared\ACADAUTO.CHM::/idh_plot_object.htm">Plot</a><br/>The object or objects this method applies to. </p><p class="element">plotConfig</p><p class="element-desc">String; input-only; optional<br/>The full path and file name of the PC3 file to use instead of the current configuration. If this parameter is not provided, the current configuration will be used. If the configuration file is not found at the specified path, AutoCAD will search the printer configuration path for the file before it defaults to the current configuration. </p><p class="element">RetVal</p><p class="element-desc">Boolean </p><p class="Constant">TRUE: The plot was successfully sent to the device.
</p><p class="Constant">FALSE: The plot was not sent to the device. There was either a plot process failure or the plot was cancelled.
</p><p class="Heading-2">Remarks </p><p class="body">The drawing from which the plot is initiated must be active for the plot to succeed. </p><p class="body">To plot in the foreground using VBA, you must set the BACKGROUNDPLOT system variable to 0. Otherwise, plotting occurs in the background. </p><p class="body">The plot device is specified using the <a href="mk:@MSITStore:D:\Program%20Files\Common%20Files\Autodesk%20Shared\ACADAUTO.CHM::/idh_configname.htm">ConfigName</a> property for the layout or plot configuration. </p><p class="body">If the PC3 file specified or the current plot configuration contains plot-to-file information, this method may actually send the plot to a file instead of to a device. Be careful to review all current plot configuration information for the specified layout. To plot several layouts, you can use the <a href="mk:@MSITStore:D:\Program%20Files\Common%20Files\Autodesk%20Shared\ACADAUTO.CHM::/idh_SetLayoutsToPlot.htm">SetLayoutsToPlot</a> method before invoking the PlotToDevice method. </p><p class="body">To create a new configured plotter (PC3) file, use the Add-a-Plotter wizard in AutoCAD. For more information about PC3 files, see "Set Up Plotters and Printers" in the AutoCAD <em class="Emphasis">Driver and Peripheral Guide</em>. </p>
页:
[1]