Steel.Detailer
Usenet Archive
- Joined
- Dec 22, 2003
- Messages
- 4
- Reaction score
- 0
I've been trying to figure out how to use the "BeginQuit" event with little success. I'm a novice at VBA in AutoCad, so please don't go too fast!! I've tried to follow the instructions in the "VBA help", but seem to be missing something....
I've created a Class Module called "EventClassModule" and have the following code in it:
Public WithEvents ACADApp As AcadApplication
Public WithEvents AcadDocument As AcadDocument
I've put the tried the following code in both the "this drawing" object and a module called "module1":
Sub 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") 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
It doesn't seem to work either way. the "AcadApplication_Events" sub says that "this has to be run first".....how do I do that? I suspect this may be my problem, but.....
Thanks in Advance!!!
Rich
I've created a Class Module called "EventClassModule" and have the following code in it:
Public WithEvents ACADApp As AcadApplication
Public WithEvents AcadDocument As AcadDocument
I've put the tried the following code in both the "this drawing" object and a module called "module1":
Sub 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") 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
It doesn't seem to work either way. the "AcadApplication_Events" sub says that "this has to be run first".....how do I do that? I suspect this may be my problem, but.....
Thanks in Advance!!!
Rich