vba 求救

来源:百度知道 编辑:UC知道 时间:2024/06/08 09:48:57
Private Sub AcadDocument_EndSave(ByVal pPicPath As String)
……
Dim blnRet As Boolean
blnRet = ThisDrawing.Plot.PlotToFile("E:\temp.dwf", "F:\DWF6
ePlot.pc3")
……
End Sub
这个是死循环,PlotToFile又调用了AcadDocument_EndSave方法,请问怎么解决?????
我的ThisDrawing.Plot.PlotToFile("E:\temp.dwf", "F:\DWF6 ePlot.pc3")是在点击保存之后出发的,只有点击保存才会自动打印输出。我现在的问题是:点击保存之后当程序走到打印时,它又回到Private Sub AcadDocument_EndSave并且在打印之前的变量的值都变成空了。 PlotToFile是自动调用保存事件的。是cad写死的

可以在begincommand中判断是不是使用保存命令,如果是,则执行打印。

详细看以下例子,经测试通过。

'Running when begin saveing
Private Sub AcadDocument_BeginSave(ByVal FileName As String)
'nothing
End Sub

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If CommandName = "QSAVE" Then'你按保存、使用保存命令都是QSAVE,要大写,如果是另存为则为SAVEAS
Dim blnRet As Boolean
blnRet = ThisDrawing.Plot.PlotToFile("E:\temp.dwf", "DWF6 ePlot.pc3")

End If
End Sub

'Running when finish saveing
Private Sub AcadDocument_EndSave(ByVal FileName As String)
'这里面不用写代码,EndCommand是在EndSave完成后才执行的,也就是说保存完成后再执行。
End Sub

有EXCEL中可以用
Application.EnableEvents = False
关闭事件,你在你这个应用中,也找一下用什么暂时关闭事件吧!

在某个方法中加上个判断,达到你要的条件后让他跳转到你要去的位置就OK了呀。