Ted Schaefer
2004-05-06 03:40:37 UTC
I was using the built-in AcadDocument (AcadDocument_BeginCommand and
added AcadDocument_EndCommand, etc). I also declared
oDwg as an AcadDocument withevents. I found that if I didn't have
matching Subs for both document objects, the AcadDocument
would stop triggering on events. On a bigger version of this routine,
I got it all working without the shadow functions, but if I did a "saveas"
to a new dvb file, the events would stop.
The problem started when I added AcadDocument_EndCommand
without adding the shadow, oDwg _EndCommand, even though I had
no reason to use it.
If curious, you can comment out the oDwg Subs and see the matching
AcadDocument subs stop working. This was a real hair puller.
If anyone can verify this or offer an explanation why this is true, I'd like
to know.
Cheers, Ted Schaefer
Option Explicit
Public WithEvents oDwg As AcadDocument
Public Sub acadstartup()
Set oDwg = ThisDrawing
End Sub
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Debug.Print "BgCmd: " & CommandName
End Sub
Private Sub AcadDocument_BeginSave(ByVal FileName As String)
Debug.Print "BgSv: " & FileName
End Sub
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
Debug.Print "EndCmd: " & CommandName
End Sub
Private Sub oApp_BeginSave(ByVal FileName As String)
End Sub
Private Sub oDwg_BeginCommand(ByVal CommandName As String)
Debug.Print "BgCmd2: " & CommandName
End Sub
Private Sub oDwg_BeginSave(ByVal FileName As String)
Debug.Print "BgSv2: " & FileName
End Sub
Private Sub oDwg_EndCommand(ByVal CommandName As String)
Debug.Print "EndCmd2: " & CommandName
End Sub
added AcadDocument_EndCommand, etc). I also declared
oDwg as an AcadDocument withevents. I found that if I didn't have
matching Subs for both document objects, the AcadDocument
would stop triggering on events. On a bigger version of this routine,
I got it all working without the shadow functions, but if I did a "saveas"
to a new dvb file, the events would stop.
The problem started when I added AcadDocument_EndCommand
without adding the shadow, oDwg _EndCommand, even though I had
no reason to use it.
If curious, you can comment out the oDwg Subs and see the matching
AcadDocument subs stop working. This was a real hair puller.
If anyone can verify this or offer an explanation why this is true, I'd like
to know.
Cheers, Ted Schaefer
Option Explicit
Public WithEvents oDwg As AcadDocument
Public Sub acadstartup()
Set oDwg = ThisDrawing
End Sub
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Debug.Print "BgCmd: " & CommandName
End Sub
Private Sub AcadDocument_BeginSave(ByVal FileName As String)
Debug.Print "BgSv: " & FileName
End Sub
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
Debug.Print "EndCmd: " & CommandName
End Sub
Private Sub oApp_BeginSave(ByVal FileName As String)
End Sub
Private Sub oDwg_BeginCommand(ByVal CommandName As String)
Debug.Print "BgCmd2: " & CommandName
End Sub
Private Sub oDwg_BeginSave(ByVal FileName As String)
Debug.Print "BgSv2: " & FileName
End Sub
Private Sub oDwg_EndCommand(ByVal CommandName As String)
Debug.Print "EndCmd2: " & CommandName
End Sub