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?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

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:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,026
Messages
5,856,930
Members
431,839
Latest member
Guest user

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top