minimising workbook while having the active form open

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Everyone!!!

I am developing an application in excel where I have to move back and forth
between user forms and spread sheets. I am not sure what I need is possible
to achieve in excel. My need is as follows:

when I open the workbook, 'user form 1' should show up and the worksheet
should minimize. In the user form, when I click ok, it should bring up the
minimized worksheet. Once I am done working on that worksheet and hit ok, I
want the worksheet to get minimized again and bring up 'user form 2' to show
up.

Is this possible?!! Please suggest me if there is a better way to achieve
this. Thanks a lot for all your help in advance.

KT
 
first, you'll need to open the form "modeless"

In a standard module:
Sub ShowForm1()
UserForm1.Show vbModeless
End Sub

Your userform1 will have an OK button (btOK) and you'll need to check if OK
was clicked once - to show the workbook - or twice to minimize the book and
show userform2.

Add this code to Userform1:-

Option Explicit
Private mClickedOnce As Boolean
Private Sub UserForm_Initialize()
Application.WindowState = xlMinimized
End Sub

Private Sub btOK_Click()
If mClickedOnce Then
Application.WindowState = xlMinimized
Me.Hide
UserForm2.Show False
Else
mClickedOnce = True
Application.WindowState = xlNormal
End If
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

Back
Top