I have a userform with multiple buttons.
I don't want to focus on any.
Is there a way to do this.
Or alternative focus on the Close (X) button using ".SetFocus".
I have a userform with multiple buttons.
I don't want to focus on any.
Is there a way to do this.
Or alternative focus on the Close (X) button using ".SetFocus".
When a form is displayed, the default focus is on the first control in the form. You can set it to any control you want (it can even be a label) but it cannot be nothing. The X button is not part of the form, it's part of the Windows frame, so you cannot set focus using VBA built-in calls. It might be possible by calling the Windows API but I do not know how to do that.
What else is on the form besides the buttons?
If you give more background about what you are doing we might be able to suggest an alternative design that meets your underlying requirements.
Jeff
| | |·| |·| |·| |·| | |:| | |·| |·|
Read the rules
Use code tags to [code]enclose your code![/code]
I don't think that you can set focus on a label, Jeff.
Setting focus on a textbox with a zero width and height is one workaround.
jason.b75, you are correct. Labels have the SetFocus method so I thought it would work, but it causes a runtime error.
OK thanks for the input. I will just create another command button which is for Exit.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks