View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
jjk jjk is offline
external usenet poster
 
Posts: 42
Default Help with vbModeless

Hi,

As Dales said with vbModal the user has to interact only with the
active modal form.
With vbModeless the user is free to interact with other forms or the
excel workbook in the back.

Now the reason you are getting the error is that you are using the
module name to load and show the object.
Let me rephrase.
You are using Userform1.show.
This means that for every call of that VBA would Load and then show the
common object associated with the module. A better approach would be to
create an object of the module load it and then show it. I guess some
code will better demonstrate it.

FORM1 LAUNCHES FROM THE EXCEL WORKSHEET USING A BUTTON
--------------------
Private Sub CommandButton1_Click()

Dim frm1 As New UserForm1
Dim frm2 As New UserForm2
Load frm1
Load frm2

Do While True
frm1.Show
frm2.Show
Loop

Unload frm1
Unload frm2

End Sub
----------------

FORM 1 IS
----------------
Private Sub CommandButton1_Click()
Me.Hide
End Sub
----------------

FORM 2 IS
----------------
Private Sub CommandButton1_Click()
Me.Hide
End Sub
----------------


I havent tested the code. This is at the present in an infinite loop.
You can get out of it by hitting ctrl+Break.

Another implementaion would be
FORM1 LAUNCHES FROM THE EXCEL WORKSHEET USING A BUTTON
--------------------
Private Sub CommandButton1_Click()

Dim frm1 As New UserForm1
Load frm1

frm1.Show

Unload frm1

End Sub
----------------

FORM 1 IS
----------------
Private Sub CommandButton1_Click()
Dim frm2 As New UserForm2
Load frm2
frm2.Show
Unload frm2
End Sub
----------------

FORM 2 IS
----------------
Private Sub CommandButton1_Click()
Me.Hide
End Sub
----------------


Hope this helps you understand modal forms better.
Regards,
Jayant