Anomaly with MS Forms Focus Indication Using VBA SetFocus

31 Views Asked by At

By default, the MS Forms Control that currently has the Focus is Highlighted with a Dotted Rectangle

Setting the TakeFocusOnClick Property of a Control to FALSE prevents this; the Control's appearance is unchanged when it has the Focus

However, this only holds true for User Input; if you use the SetFocus Method to programmatically assign the Focus to a Control it will ALWAYS be Highlighted, regardless of it's TakeFocusOnClick Property

A common workaround is to reassign the Focus to a "Hidden" Control, but this gets messy

Does anyone know of a more elegant way to hide this Highlighting when using SetFocus?

1

There are 1 best solutions below

0
Stringeater On

It will be highlighted as well when you cycle with the tab key through the controls of when you press the accelerator key on the keyboard. And as another side effect the former control loses focus.

You can avoid this by using a windowless control, eg. a label or an image. With UserControls you could design your own windowless control.