Consulting

Results 1 to 13 of 13

Thread: Show UserForm With Application.Visible = False

  1. #1
    VBAX Regular
    Joined
    May 2017
    Posts
    26
    Location

    Show UserForm With Application.Visible = False

    Hi!
    Is it possible to only hide the excel application for a specific workbook or something similar?

    Im using this code

    Private Sub Workbook_Open()
           Application.Visible = False
           UserForm4.Show
    End Sub
    to only show the userform, while excel is hidden for the user. It does however cause problems if the user already opened other excel workbooks. Only idea i got so far is unhiding by using Application.Visible = True as the user clicks an image used to close the userform. Not the best solution though as he can't work with other excel sheets while using my userform.

    Any suggestions?

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Private Sub Workbook_Open()
        ActiveWindow.WindowState = xlMinimized
        Userform4.Show
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    May 2017
    Posts
    26
    Location
    Tried it, opens the workbook minized (as it is supposed to do i guess?) but doesnt show the userform. Additionally it crashes in a weird way (not able to click or select anything in excel, only able to exit by using task manager).

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try opening non-modal (I didn't test opening as modal)
    Userform4.Show 0
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Regular
    Joined
    May 2017
    Posts
    26
    Location
    Thank you, but its still not doing the job. Now it opens Excel minimized, the application works, but the userform does not show up.

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Does it work if you run it from the VBE
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Regular
    Joined
    May 2017
    Posts
    26
    Location
    I assume VBE means VB-Explorer/Editor and tried running it out of the above code. Nothing happened.

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Can't think of anything else. Can you post your workbook?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by Olwa View Post
    ...It does however cause problems if the user already opened other excel workbooks. Only idea i got so far is unhiding by using Application.Visible = True as the user clicks an image used to close the userform. Not the best solution though as he can't work with other excel sheets while using my userform...
    Greetings,

    I'm not sure if you are trying to hide the entire app, or just the workbook. If the latter, maybe something along the lines of:

    ThisWorkbook Code:
    Option Explicit
      
    Private frmUserForm1 As UserForm1
      
    Private Sub Workbook_Open()
      Set frmUserForm1 = New UserForm1
      ThisWorkbook.IsAddin = True
      frmUserForm1.Show vbModeless
    End Sub
    Userform Code:
    Option Explicit
    
    
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
      ThisWorkbook.IsAddin = False
    End Sub
    Hope that helps,

    Mark

  10. #10
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I don't think you can hide the Application, since I think that also hides all the App's child processes.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  11. #11
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Sam,

    You can show the form vbModeless after hiding the app.

    Standard Module:
    Option Explicit
    
    
    Private formUserform1 As UserForm1
    
    
    Sub HideAppShowForm()
      
      Set formUserform1 = New UserForm1
      Application.Visible = False
      formUserform1.Show vbModeless
      
    End Sub
    Userform Code:
    Option Explicit
    
    
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
      Application.Visible = True
    End Sub
    Mark

  12. #12
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Thanks Mark, Good to know.
    I will now change the thread Title to
    Show UserForm With Application.Visible = False
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  13. #13
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Olwa
    Is this solved?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Tags for this Thread

Posting Permissions

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