[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Trigger an Excel VBA event from another application

Mike

12/14/2006 2:49:00 AM

I can send a message to a dotNet Textbox and have it trigger the
TextBox_Change event. What I want to do is the reverse. I want to send a
message from dotNet to Excel VBA and have it trigger some event so I can
immediately respond to the event. Since I can't get a Handle for any of the
VBA controls, I'm not having much luck. I can send a message that changes
the Form Caption but this doesn't trigger any event that I can find, and I
want to stay away from a polling technique.

Any ideas would be appreciated.

mike


4 Answers

NickHK

12/14/2006 3:36:00 AM

0

Mike,
Since you can't get the HWnd, SendMessage is useless.
Can you not use Automation to control Excel ?

NickHK

"Mike" <mikea365h@hotmail.com> wrote in message
news:12o1et99choc929@corp.supernews.com...
> I can send a message to a dotNet Textbox and have it trigger the
> TextBox_Change event. What I want to do is the reverse. I want to send a
> message from dotNet to Excel VBA and have it trigger some event so I can
> immediately respond to the event. Since I can't get a Handle for any of
the
> VBA controls, I'm not having much luck. I can send a message that changes
> the Form Caption but this doesn't trigger any event that I can find, and I
> want to stay away from a polling technique.
>
> Any ideas would be appreciated.
>
> mike
>
>


Mike

12/14/2006 4:57:00 AM

0

I'm not familiar with Automation. If you could give me just a few more
words, I could start Googlin'.

thanks

"NickHK" <TungCheWah@Invalid.com> wrote in message
news:%237FL4DzHHHA.320@TK2MSFTNGP06.phx.gbl...
> Mike,
> Since you can't get the HWnd, SendMessage is useless.
> Can you not use Automation to control Excel ?
>
> NickHK
>
> "Mike" <mikea365h@hotmail.com> wrote in message
> news:12o1et99choc929@corp.supernews.com...
>> I can send a message to a dotNet Textbox and have it trigger the
>> TextBox_Change event. What I want to do is the reverse. I want to send a
>> message from dotNet to Excel VBA and have it trigger some event so I can
>> immediately respond to the event. Since I can't get a Handle for any of
> the
>> VBA controls, I'm not having much luck. I can send a message that changes
>> the Form Caption but this doesn't trigger any event that I can find, and
>> I
>> want to stay away from a polling technique.
>>
>> Any ideas would be appreciated.
>>
>> mike
>>
>>
>
>


NickHK

12/14/2006 6:08:00 AM

0

Mike,
I don't use .net language, but you need Interop etc AFAIK.
Here's a start :
http://support.microsoft.com...

NickHK

"Mike" <mikea365h@hotmail.com> wrote in message
news:12o1mdmsu2t400e@corp.supernews.com...
> I'm not familiar with Automation. If you could give me just a few more
> words, I could start Googlin'.
>
> thanks
>
> "NickHK" <TungCheWah@Invalid.com> wrote in message
> news:%237FL4DzHHHA.320@TK2MSFTNGP06.phx.gbl...
> > Mike,
> > Since you can't get the HWnd, SendMessage is useless.
> > Can you not use Automation to control Excel ?
> >
> > NickHK
> >
> > "Mike" <mikea365h@hotmail.com> wrote in message
> > news:12o1et99choc929@corp.supernews.com...
> >> I can send a message to a dotNet Textbox and have it trigger the
> >> TextBox_Change event. What I want to do is the reverse. I want to send
a
> >> message from dotNet to Excel VBA and have it trigger some event so I
can
> >> immediately respond to the event. Since I can't get a Handle for any of
> > the
> >> VBA controls, I'm not having much luck. I can send a message that
changes
> >> the Form Caption but this doesn't trigger any event that I can find,
and
> >> I
> >> want to stay away from a polling technique.
> >>
> >> Any ideas would be appreciated.
> >>
> >> mike
> >>
> >>
> >
> >
>
>


abhimanyu

12/14/2006 9:21:00 AM

0

Mike,

You can call a method in Excel VBA from .NET assembly but you cannot
get an event back in the assembly from VBA code.
If this is what you want to do, get the Primary Interop Assemblies for
Excel, reference them in your .NET project and use the
Excel.Application object. A method named "Run" is used to call a VBA
macro.

regards