+ Reply to Thread
Results 1 to 7 of 7

Maximize Userform on Workbook Active

Hybrid View

  1. #1
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Maximize Userform on Workbook Active

    Hi Guys,

    I have a UserForm that automatically displays when a Workbook opens; the userform allows the user to create 2 new workbooks from the data they have entered. Unfortunately, the user can't select the new workbooks without closing the Userform. For this reason, I have added a minimize button to the userform:
    Private Sub CommandButton24_Click()
    frmMain.Hide
    Application.WindowState = xlMinimized
    End Sub
    However, when the user reselects the workbook the userform doesn't show again and they are able to see the sheets behind it. Would it be possible to redisplay the userform if the workbook becomes active again. I have tried this code but it doesnt seem to work:

    Private Sub Workbook_Activate()
    frmMain.Show
    
    End Sub

    Thanks in advance for your help.
    Last edited by savio21; 12-06-2011 at 03:01 PM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Maximize Userform on Workbook Active

    this will suffice:

    Private Sub CommandButton24_Click()
      frmMain.Hide
    End Sub
    Private Sub Workbook_Activate()
      frmMain.Show
    End Sub



  3. #3
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Maximize Userform on Workbook Active

    It doesn't appear to work. My main goal is to prevent the user from seeing the worksheets behind the userform (mainly for security reasons so they don't screw anything up). Should I add this code to a separate module or just to the "This Workbook" object.

  4. #4
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Maximize Userform on Workbook Active

    It appears to be working now. Thanks again!

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Maximize Userform on Workbook Active

    Private Sub CommandButton24_Click()
      frmMain.Hide
    End Sub
    Private Sub Workbook_Open()
      frmMain.Show
    End Sub

  6. #6
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Maximize Userform on Workbook Active

    I have both codes now:
    Private Sub Workbook_Activate()
      frmMain.Show
    End Sub
    and
    Private Sub Workbook_Open()
      frmMain.Show
    End Sub
    which works great if there is another workbook open. Unfortunately, it doesn't work if its the only Workbook open. I'm using this code to minimize the application and the userform:
    Private Sub CommandButton24_Click()
    frmMain.Hide
    Application.WindowState = xlMinimized
    End Sub
    I would like the userform to be displayed if the user selects the workbook again. Hope that makes sense!!

  7. #7
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Maximize Userform on Workbook Active

    Is there a way to ensure the userform displays if the workbook is maximized? If not I may need to add a workaround.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1