Author Topic: App Events not working  (Read 18461 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Re: App Events not working
« Reply #15 on: July 11, 2007, 05:23:07 PM »

R 16.2

Land Desktop 2006

Thanks Jeff!

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: App Events not working
« Reply #16 on: July 11, 2007, 07:04:06 PM »
OK, the attached acad.dvb is working. While doing this I recalled having all kinds of problems using this Class module method which is why mine all resides in ThisDrawing module. I'm still not sure why the Help says to do it one way that you, nor I, could make work.

Bryco

  • Water Moccasin
  • Posts: 1882
Re: App Events not working
« Reply #17 on: July 11, 2007, 08:21:08 PM »
Quote
I could be wrong but it looks like you are grabbing the events from drawing level instead of from The system?
As far as I know vba needs a drawing open to access the application, Jeff any thoughts?

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: App Events not working
« Reply #18 on: July 11, 2007, 08:31:08 PM »
I don't know for sure, but that's how I've always thought it works. I was confused about that as well.

DaveW

  • Guest
Re: App Events not working
« Reply #19 on: July 12, 2007, 01:29:27 AM »
Sounds right to me. VBA does appear to disappear without a drawing opne. I have always use the right menu to do this, but I like your way better Bryco. Thanks for sharing that.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: App Events not working
« Reply #20 on: July 12, 2007, 09:04:14 AM »
A drawing does not need to be open to use the VBA environment, however, a drawing does need to be open to enable the environment.

Consider this:

Load the previously attached acad.dvb and create an event for opening a drawing and/or creating a new drawing.
Save the dvb
Close AutoCAD
Re-open AutoCAD, note that no events fire as the first drawing is already open by the time the VBA environment initializes.
Close that drawing so there are no drawings currently open, presumably the VBA environment is now inactive.
Create a new drawing, note how the events fire just prior to refreshing the window.

Another exercise is to create a timer module that sets a system timer. Set the timer to call a macro to pop up a window every minute. Run the timer macro and close all open drawings. Presumably the timer would not be able to find the macro to call if the VBA environment is inactive while there are no drawings open, but it does fire, and it does find the macro.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ML

  • Guest
Re: App Events not working
« Reply #21 on: July 12, 2007, 09:52:01 AM »

Keith,

Please, as per previous disussions, isn't it correct that VBA needs to be initialized on startup in order to use APP Level Events?

May be you know why The Class Module isn't working?

I know it use to work for me in previous positions.

Thanks

Mark

ML

  • Guest
Re: App Events not working
« Reply #22 on: July 12, 2007, 09:53:43 AM »


Jeff

I haven't tried it yet but thank you, I will try it now.
However, I suspect that if we are using The document (thisdrawing) method, we are still not going to be able to initiate APP level events, only drawing level.

Please correct me if I am wrong  :-o

Thank you again

Mark

ML

  • Guest
Re: App Events not working
« Reply #23 on: July 12, 2007, 09:55:45 AM »


To continue that discussion, VBA sure can be initialized without a drawing open. It can be initialized on startup.
Please look at my very first post at the top.

Mark

Bryco

  • Water Moccasin
  • Posts: 1882
Re: App Events not working
« Reply #24 on: July 12, 2007, 10:04:12 AM »
Ml use the thisdrawing module, it does what you ask.
Keith, once you have set the application (And this happens when a drawing is opening as in opening autocad) you can close all drawings and the vba is still running, like you said. However if the link is broken, you can't reset the application while there is no drawing open, it errors

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: App Events not working
« Reply #25 on: July 12, 2007, 10:43:46 AM »
Mark, In the revised acad.dvb that I posted I don't use any reference to ThisDrawing. Out of curiosity, what are you trying to catch/control that you wouldn't have a drawing open?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: App Events not working
« Reply #26 on: July 12, 2007, 10:55:35 AM »
Correct, you cannot restart the application link from within VBA by creating a new link, but that link will always be active until the application is closed or the variable holding the application is destroyed
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ML

  • Guest
Re: App Events not working
« Reply #27 on: July 12, 2007, 11:02:15 AM »

Yes Jeff, I see that now, thank you
However, niether of these test events are working ????

Code: [Select]
Private Sub ACADApp_BeginPlot(ByVal DrawingName As String)

MsgBox "A drawing has just received a request to plot for: " & DrawingName

End Sub
[code]


Private Sub ACADApp_EndSave(ByVal FileName As String)
MsgBox ThisDrawing.FullName & "Has Been Saved"
End Sub
[/code]


Bryon-Jeff

How do you guys initialize VBA on startup?

Mark




ML

  • Guest
Re: App Events not working
« Reply #28 on: July 12, 2007, 11:07:29 AM »

Jeff, All of sudden it is working just fine!

That's great, thank you very much

Mark

ML

  • Guest
Re: App Events not working
« Reply #29 on: July 12, 2007, 11:12:11 AM »


OK, this is a very naive question:

Jeff:

In the exposeappevents module
You have the code


Code: [Select]
Dim AppEvents As New EventsClass
-----------------------------------------
Sub acadstartup()
 
Set AppEvents.ACADApp = Application

End Sub

I understand that you made a new class module but what is actually triggering it (acadstartup)?

THanks

Mark