Use event to catch the running of a macro from an add-in

  • Thread starter Thread starter legacyvbc
  • Start date Start date
L

legacyvbc

Is there a way to determine when a macro from a 3rd-party add-in has
started running and when it has finished?

For example, lets say I have a 3rd party add-in that downloads data
from the internet and has a custom menu called Custom with a submenu
called Download. If I select download I would like to "catch" that it
was called and set application.enableevents to false and then whenever
it is done I would like to turn it back on.

Is this possible?
Thanks
 
First thing I would try is to see if you can determine the name of the
sub called by the Download menu item... View (menu) | Tools | Customize
and right-click the menu item and see what "assign macro" tells you.

If that works then substitute your own sub for the one assigned to the menu item.
'--
Sub MySubstitue()
On Error GoTo BadChoice
Application.EnableEvents = False
Call MacroAssignedToMenuItem
BadChoice:
Application.EnableEvents = True
End Sub
--

Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




<[email protected]>
wrote in message
Is there a way to determine when a macro from a 3rd-party add-in has
started running and when it has finished?

For example, lets say I have a 3rd party add-in that downloads data
from the internet and has a custom menu called Custom with a submenu
called Download. If I select download I would like to "catch" that it
was called and set application.enableevents to false and then whenever
it is done I would like to turn it back on.

Is this possible?
Thanks
 
I failed to renew my psychic hotline subscription.
No luck means what? ...
Couldn't find a macro name? or the MySubstitute sub failed at the "something"
line with a "description here" error? or Excel crashed? or ...
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



<[email protected]>
wrote in message
No luck - any other ideas?
Thanks
 
As far as I know there's no way to put a "watch" on a particular macro so
you can know when it runs (and any watching code could not run at the same
time as the watched macro...)

If you just want to make the 3rd party code complete more quickly then you
could wrap a call to it in another sub and call it via that.

Eg:

Sub Wrapper()
application.enableevents=false
application.run ThirdPartyMacroName
application.enableevents=true
end sub

However if the 3rd party macro switches event handling back on you can't
prevent that. Also, if it operates asynchronously your timing will be off.

Tim
 
No luck meaning that I can't see the name of the sub. The macro is
called by a dll so I don't know how to figure out what call that is.
I am guessing it just isn't possible.

Thanks
 
Maybe, but it still all starts by clicking the "Download" menu item.
So run your own sub when you want to "download"...
'--
Sub MakeItHappen
On Error GoTo Snafu
Application.EnableEvents = False
Application.CommandBars(1).Controls("Custom").Controls("Download").Execute
Snafu:
Application.EnableEvents = True
End Sub
'--
Above assumes the Custom menu is on the menu bar.
Also, as Tim Williams pointed, out that you can't control whether the
Download routine switches Events back on or when it finishes.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)





<[email protected]>
wrote in message
No luck meaning that I can't see the name of the sub. The macro is
called by a dll so I don't know how to figure out what call that is.
I am guessing it just isn't possible.
Thanks
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top