Link to home
Start Free TrialLog in
Avatar of powermixx
powermixx

asked on

Behavior entering field

I have code that requires the "behavior entering field" param (Tools|Options|Keyboard) to be set to "Select Entire Field". If a user has this set differently, my code will not work.

How can I make sure this setting is how I need it for my code to work properly?
Avatar of paasky
paasky
Flag of Finland image

Hello powermixx,

You could ensure that running this function in your application startup:

Public Function SetKeyboardOption()
    Application.SetOption "Behavior Entering Field", 0
End Function

Regards,
paasky
Avatar of ShoeBooty
ShoeBooty

powermixx,

In regards to paasky's comment, I would suggest that you first evaluate whether or not the option is set properly to begin with.  Then, if it is not, you can use paasky's solution.  Storing the results of this evaluation (yes/no) in a global variable will also enable you to return each users PC to the original configuration when your code is complete.  I have found that this works well to prevent users from complaining that I have changed settings that they have set for their preferences.

Shoe
ASKER CERTIFIED SOLUTION
Avatar of paasky
paasky
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note: Behavior Entering Field might have value from 0 to 2 (Integer) and they're in the same order as Tools-Options-Keyboard Dialog.
Another thought . . . since this is an application-wide setup option (and some users set up there Tools | Options to not select the entire field on purpose) I would think that you would either want to reset the option when you application exits, or if this is for just one field, you could put a

SendKeys "{F2}"

on the Enter event; this toggles Edit mode between highlight and cursor.

brewdog
Avatar of powermixx

ASKER

Apologies for taking a few days. Works very busy. Thanks Paasky.