View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ronald Dodge Ronald Dodge is offline
external usenet poster
 
Posts: 111
Default How to catch mouse/keyboard event in Office addin

After looking into it, you may want to take a look at the following code:

Take a look at the OnAction property of a CommandButton

Example:

Application.CommandBars("Worksheet Menu
Bar").Controls("&Edit").Controls("Can't &Undo").OnAction =
<StringNameOfMacro

This is how you would set the name of the macro to the Click Event of the
button such as this would set some macro to the "Can't &Undo" button that's
on the "&Edit" menu, which is on the main Excel menu toolbar.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Frank King" wrote in message
...
Thank you very much for the message.

In fact, I am not using form. Instead, I am trying to
catch the mouse click or keyboard press in choosing the
menu I added with COM addin, say in EXCEL. After a user
clicks mouse button or presses the keyboard to choose a
menu (from top to the target menu), I try to start some
work, such as thread, before starting to run the function
for the target menu. For that reason, I am looking for
some methods to catch the mouse and keyboard event.

Do you have an idea about how to so?

Regards.

fk

-----Original Message-----
When working with forms, each of the different objects

including ActiveX
objects has the different Events. To look up the events,

right click on the
Object, then click on Properties
Now click on "Event" tab.

It's in there where you have MouseDown, MouseMove,

MouseUp, KeyDown,
KeyPress, and KeyUp events, if available, which should be

in a good majority
of the cases. Now click on one of those events, click on

the "..." to the
right of it, then click on "Code"

If you have created your own objects, you will also have

to create the
events for that object in a class module of the object

that deals with using
the WithEvents command, something I still have yet to

learn more about.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Frank King" wrote in message
...
Hi,

I am writing Office COM addin. I need to catch mouse/
keyboard events, such as mouse click, key press inside
the addin. Could somebody tell me some information
about it?

Thank you very much.

fk




.