Modal/Modeless User Forms

C

Conan Kelly

Hello all,

Inside a Do...While loop I show a user form. Right before the user form is displayed, the code selects some text. The user form
asks if the selected text is correct with yes, no, and cancel buttons.

What I need it to do is display the form as modeless WITHOUT continuing code execution. I need it to be modeless so I can scroll
the document to see if the selected text is correct, since the selected text is larger than the screen. If I show the form as
modal, I can't scroll the window. If I show the form as modeless, the code continues to execute.

How can I show the form as modeless, but pause code execution until a button on the form is clicked?

Thanks for any help anyone can provide,

Conan Kelly
 
R

Robert Paulsen

The following code worked for me. I added a user form with one button. I was
able to scroll the document while the form was showing, and once I clicked ok
I saw a message box I inserted in the command button, hid the form, and then
received my message box after the Do...Loop. If using the Visible property of
the form isn't satisfactory, you can add a Public property to the form and
set it to the appropriate value in your command button (i.e. Do While
myForm.myProperty = False).

Dim myForm As New UserForm1

myForm.Show 0

Do While myForm.Visible
DoEvents
Loop
MsgBox "xxx"
 

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