vb command to snap to default button

Reset

Board Regular
Joined
Apr 16, 2010
Messages
227
Is there a command to have the pointer snap to the default selection in a msgbox?
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

AgentSmith

Well-known Member
Joined
Mar 8, 2004
Messages
575
There is a Windows setting for that so perhaps there might be an API call you can use. To find it in Windows yourself have a look at the mouse settings in Control Panel. There should be a tick box labelled "Automatically move pointer to the default button in a dialog box" or something similar.

On a related note, you can control which button is the default on a MsgBox. E.g. instead of just "vbYesNo" try "vbYesNo + vbDefaultButton2" to make No the default option. This allows you to change what happens when the user presses the ENTER key, which might be a good half-way house?
 

AgentSmith

Well-known Member
Joined
Mar 8, 2004
Messages
575
PS - personally I'd avoid doing exactly what you propose. Some people like the mouse to do that, others don't. Those that do like it can tick the box in Control Panel (or you can show them how) so why interfere? You might just confuse the people you are trying to help!
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,109,083
Messages
5,526,753
Members
409,717
Latest member
Oscarsalone

This Week's Hot Topics

Top