Selecting a combo box in a nonmodal user form

B

Bear

Hello:

I have a user form with a combo box that shows the style of the selection.
I'm displaying the user form in nonmodal fashion. How do I get that combo box
to have focus AND show the current text as being selected?

When ShowModal is True, using the SetFocus method highlights the combobox
text. When ShowModal is False, it doesn't. Neither do the SelStart and
SelLength properties work.

Any ideas?

Bear
 
B

Bear

To bring this thread up to date and conclude my search for an answer...
There's no "good" way to set the focus to a combobox in a modeless form. The
ugly workaround is to set focus to another control, then back to the combobox.

Here's what I ended up doing...

Sub ReplaceStyles()

' Replaces paragraph or character styles

Dim MyForm As frmReplaceStyles
Set MyForm = New frmReplaceStyles
MyForm.Show

' Workaround to set focus in modeless form

MyForm.cmdCancel.SetFocus
MyForm.cboFindStyleName.SetFocus

Set MyForm = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top