关闭AutoCAD时的事件
当有人想在结束绘图时启动某项操作时,他可以使用“中的共同响应事件”;本图纸;然而,I';当整个程序关闭时,需要编写一些东西。那么,在关闭AutoCAD时是否有类似的事件?来自acad activex帮助的所有信息Public WithEvents ACADApp As AcadApplication ' Use with Application Event Examples
Sub Example_AcadApplication_Events()
' This example intializes the public variable (ACADApp) which will be used
' to intercept AcadApplication Events
'
' The VBA WithEvents statement makes it possible to intercept an generic object
' with the events associated with that object.
'
' Before you will be able to trigger any of the AcadApplication events,
' you will first need to run this procedure.
' We could get the application from the ThisDocument object, but that would
' require having a drawing open, so we grab it from the system.
Set ACADApp = GetObject(, "AutoCAD.Application.16")
End Sub
Private Sub ACADApp_BeginQuit(Cancel As Boolean)
' This example intercepts an Application BeginQuit event.
'
' This event is triggered when AutoCAD receives a request to shut down.
'
' To trigger this example event:
' 1) Make sure to run the example that initializes
' the public variable (named ACADApp) linked to this event.
'
' 2) Close the AutoCAD application
' Use the "Cancel" variable to stop the shut down of the application
If MsgBox("AutoCAD is about to shut down.Do you want to continue with the shutdown?", vbYesNoCancel + vbQuestion)vbYes Then
Cancel = True
End If
End Sub
我承认我没有';我不理解MsgBox的用法,但谢谢;我要试试看!
我只是想证明事件可以被捕获,并且陷阱的返回值决定应用程序是否关闭
我们有同样的想象力,克里
克里现在将消失三个小时,因为他';s蜷缩在一个角落里,以胎儿的姿势,抱着他的小弟弟,问宇宙:“我不知道。”;为什么&引用; 你能再帮我一点忙吗?我使用了代码,但我没有#039;我什么都做不了。顺便说一句,我意识到Public WithEvents ACADApp As AcadApplication 必须将其放置在类模块中。我还添加了其他两个子模块,但当我关闭AutoCAD时,什么都没有发生…
实际上,我要做的是在AutoCAD关闭时删除一个临时文件。你能(再次)帮我吗? 你可以把所有的代码放到这个绘图模块中,这个模块是IIRC类模块
我的第一个建议是在cod的第一条线上设置一个断点。关闭autocad ;如果事件被触发,yousub将在第一行运行并停止 ;您可以使用F8逐行遍历代码,注意结果,看看是否可以解决问题
我的零级假设是,你需要摆脱错误恢复的next,这样你的例程就可以在何时以何种方式中断';如果可以的话,应该是这样的;t找出你的问题,发布你的代码,这样我们就可以玩家庭游戏了。 我把所有的代码都放在这个绘图模块中,在第一行上做了一个标记(设置ACADApp=……),但仍然什么都没有……这是我的全部代码:
Public WithEvents ACADApp As AcadApplication
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Example_AcadApplication_Events()
Set ACADApp = GetObject(, "AutoCAD.Application.16")
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub ACADApp_BeginQuit(Cancel As Boolean)
'
MySubmarine
'
If MsgBox("AutoCAD is about to shut down.Do you want to continue with the shutdown?", vbYesNoCancel + vbQuestion)vbYes Then
Cancel = True
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub MySubmarine()
Kill "c:\MyDamnStupidFile.txt"
End Sub 顺便问一下.16代码是做什么的?
。16是AC2004,在yoy使用不同版本的情况下,有几种方法可以错误捕获此错误。 看一下16版的dxf系统变量ACADVER。它们应该是:AC1018 AutoCAD 2004/2005/2006;J#039~
页:
[1]
2