Application.Visible = True and focus

H

hughie

Here's one for you..

I've got a modeless userform firing up after a 'Application.Visible =
False'. Because I want to get into the code and continue editing I've
added a 'view worksheet' button to the form that does a
'Application.Visible = True'. All is well..

...except that the worksheet is behind the userform and won't take focus
and come to the front. How can I get the two windows to behave
normally ie when you click on one it takes focus and comes to the
front?

tia,
Hughie
 
N

NickHK

Hughie,
This works for me as expected:

<Worksheet code>
Private Sub CommandButton1_Click()
UserForm1.Show vbModeless
End Sub
</Worksheet code>

<Userform code>
Private Sub cmdHideExcel_Click()
Application.Visible = False
End Sub

Private Sub cmdShowExcel_Click()
Application.Visible = True
End Sub
</Userform code>

But the worksheet will always be behind the userform, although you can still
interact with the WS; Excel is designed that way.
You can .Hide the userform if you do not want it visible, but still loaded.

NickHK
 
H

hughie

This works for me as expected:
But the worksheet will always be behind the userform, although you can still
interact with the WS; Excel is designed that way.
You can .Hide the userform if you do not want it visible, but still loaded.

Oh I see. You might expect it but I didn't (arf!). I had put in a
..hide in any case.

thanks for help :)

Hughie
 

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