Message 1 of 17
Document Activated Event
Not applicable
03-24-2000
12:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
A few weeks ago, a request was made for a component that can
provide an event when a document is activated and when
AutoCAD is closed, and a couple of other things. Since the
changes have been made to the newsgroups, I can't find the
original post nor the newsgroup search.
TrackA2K.DLL in the attached Zip file may provide a solution
for at least some of the functionality requested.
The other DLL in the Zip is XTimers.DLL, which comes with
the Coffee VB6 sample application from Microsoft.
After registering both DLLs with Regsvr32, the code you need
looks like this
Private WithEvents myDocTracks As TrackA2K.DocTracks
Private myAcad As AcadApplication
On Error Resume Next
Set myAcad = CreateObject("AutoCAD.Application.15")
If Err Then
MsgBox "Could not get an instance of AutoCAD"
Else
Set myDocTracks = New DocTracks
If Err Then
MsgBox "Could not get an instance of
TrackA2K.DocTracks"
End If
Set myDocTracks.Acad = myAcad
myAcad.Visible = True
End If
The DocTracks object exposes 3 events:
OnQuit()
Fired when the AutoCAD session exits. Set myAcad=Nothing
and myDocTracks=Nothing in this event, along with anything
else you need to do.
WillQuit()
Fired before message boxes for saving or not saving are
presented. OnQuit will not fire if cancel is chosen on any
Save prompt.
OnActivate(ByVal aDoc as AcadDocument)
Fired when a new document is opened or created.
Any comments are welcome
Mark Holder
provide an event when a document is activated and when
AutoCAD is closed, and a couple of other things. Since the
changes have been made to the newsgroups, I can't find the
original post nor the newsgroup search.
TrackA2K.DLL in the attached Zip file may provide a solution
for at least some of the functionality requested.
The other DLL in the Zip is XTimers.DLL, which comes with
the Coffee VB6 sample application from Microsoft.
After registering both DLLs with Regsvr32, the code you need
looks like this
Private WithEvents myDocTracks As TrackA2K.DocTracks
Private myAcad As AcadApplication
On Error Resume Next
Set myAcad = CreateObject("AutoCAD.Application.15")
If Err Then
MsgBox "Could not get an instance of AutoCAD"
Else
Set myDocTracks = New DocTracks
If Err Then
MsgBox "Could not get an instance of
TrackA2K.DocTracks"
End If
Set myDocTracks.Acad = myAcad
myAcad.Visible = True
End If
The DocTracks object exposes 3 events:
OnQuit()
Fired when the AutoCAD session exits. Set myAcad=Nothing
and myDocTracks=Nothing in this event, along with anything
else you need to do.
WillQuit()
Fired before message boxes for saving or not saving are
presented. OnQuit will not fire if cancel is chosen on any
Save prompt.
OnActivate(ByVal aDoc as AcadDocument)
Fired when a new document is opened or created.
Any comments are welcome
Mark Holder