明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2387|回复: 5

[VBA]关于vba在cad2005中循环打印的问题(有源码)

[复制链接]
发表于 2006-12-5 13:02:00 | 显示全部楼层 |阅读模式

我想请教 大家一个问题

我什么这段循环打印的vba程序在2002中可以使用

而在2005中只能打出一张就报错????

很不解,虚心请教

以下是源码:

Sub 批量打印()
    Dim x As Integer
    Dim i As Integer
    Dim length As Double
    Dim point1 As Variant, point2 As Variant
    Dim point3 As Variant
     Dim Message, Title, Default, MyValue
      point1 = ThisDrawing.Utility.GetPoint(, "请输入左下角点:")
    ReDim Preserve point1(0 To 1)  
    
    point2 = ThisDrawing.Utility.GetPoint(, "请输入右上角点:")
    ReDim Preserve point2(0 To 1)      
    point3 = ThisDrawing.Utility.GetPoint(, "输入第二张图纸左下角点:")
    ReDim Preserve point3(0 To 1)
  length = point3(0) - point1(0)
    
Message = "  输入打印多少张?  "

Title = "提醒:"  
Default = "1"    
x = InputBox(Message, Title, Default)
  For i = 1 To x Step 1
    
    ThisDrawing.ActiveLayout.SetWindowToPlot point1, point2
    ThisDrawing.ActiveLayout.GetWindowToPlot point1, point2
    ThisDrawing.ActiveLayout.PlotType = acWindow
    ThisDrawing.Plot.PlotToDevice        '用默认设置打印到打印机
    point1(0) = point1(0) + length:   point1(1) = point1(1)
    point2(0) = point2(0) + length:   point2(1) = point2(1)
    Next i
End Sub

 楼主| 发表于 2006-12-5 21:36:00 | 显示全部楼层

怎么没人顶

希望各位高手解答一下

发表于 2006-12-6 11:07:00 | 显示全部楼层

打印份数不需要用For...Next...语句,用这个:

Thisdrawing.Plot.NumberOfCopies = x

发表于 2006-12-6 12:09:00 | 显示全部楼层

经测试.在我这没有问题,是可以用的

 楼主| 发表于 2006-12-6 12:42:00 | 显示全部楼层

谢谢各位

我在2002中可以正常使用

而在2005中只能打出一张就报错????

不知道为什么

3楼说的可以实现循环吗,试试。。。。

发表于 2006-12-20 09:56:00 | 显示全部楼层

看cadVBA 中plottodevice method的帮助,最大的怀疑是  

你是否打印设置文件有问题?

RetVal = object.PlotToDevice [plotConfig]

Object

MSITStore:D:\Program%20Files\Common%20Files\Autodesk%20Shared\ACADAUTO.CHM::/idh_plot_object.htm">Plot
The object or objects this method applies to.

plotConfig

String; input-only; optional
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.

RetVal

Boolean

TRUE: The plot was successfully sent to the device.

FALSE: The plot was not sent to the device. There was either a plot process failure or the plot was cancelled.

Remarks

The drawing from which the plot is initiated must be active for the plot to succeed.

To plot in the foreground using VBA, you must set the BACKGROUNDPLOT system variable to 0. Otherwise, plotting occurs in the background.

The plot device is specified using the MSITStore:D:\Program%20Files\Common%20Files\Autodesk%20Shared\ACADAUTO.CHM::/idh_configname.htm">ConfigName property for the layout or plot configuration.

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 MSITStore:D:\Program%20Files\Common%20Files\Autodesk%20Shared\ACADAUTO.CHM::/idh_SetLayoutsToPlot.htm">SetLayoutsToPlot method before invoking the PlotToDevice method.

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 Driver and Peripheral Guide.

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-23 01:05 , Processed in 0.176573 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表