Missing something on the "BeginQuit" event...

Discussion in 'AutoCAD' started by Steel.Detailer, Jan 9, 2004.

  1. 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
     
    Steel.Detailer, Jan 9, 2004
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.