Prevent control taking focus when accelerator key is used?

M

Michael Jones

I can prevent a Command Button taking the focus when it is clicked, by
setting this property to false at design time.
But, this doesn't seem to work when an accelerator key is used - how do I
prevent the Command Button taking the focus when it is activated with an
accelerator key (eg Alt + 1) ?

Using Excel 2003 with Windows XP Professional.

Thanks,

Michael Jones
 
T

Tom Ogilvy

that appears to be by design. I would suggest that as the first command in
the click event you do

ActiveCell.Activate
 
M

Michael Jones

1 - Apologies if anyone received 2 identical emails from me - my email
reader did not display the 1st email I sent.

2 - Tom - thanks for your response, but as I see it I need something like
your solution when I press the (eg) Alt + 1 keys.
Is there some sort of global way to trap the Alt + 1 key combination or will
I have to do a bit of coding for each control that loses focus because of
Alt + 1 ?

Thanks,
Michael Jones
 
T

Tom Ogilvy

I tested it before I posted and it worked for me. Maybe you haven't
accurately articulated your problem. I put a 1 in the property for
accelerator for the commandbutton. My suggestion fixed the problem you
cited when I did Alt+1.
 
M

Michael Jones

Tom

Now I understand your solution and it has solved the problem.
I hadn't realized that an accelerator key produces a 'click' event. :)
It then became an easy matter to code to this event.

Many thanks,

Michael Jones
 

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

Top