Results 1 to 6 of 6

Thread: How to set the start position of a modeless user-form?

  1. #1
    Board Regular
    Join Date
    Aug 2019
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default How to set the start position of a modeless user-form?

    Hello all.

    I know how to position a modal form, but a modeless form, acting as a 'please wait' sign is not responding in the same way.
    If anyone can help I would be very grateful.

    I position a regular form with the following private sub in the forms code window

    Code:
    Private Sub UserForm_Activate()
    
        Dim TopOffset As Integer
        Dim LeftOffset As Integer
        
        TopOffset = (Application.UsableHeight / 2) - (Me.Height / 2)
        LeftOffset = (Application.UsableWidth / 2) - (Me.width / 2)
        
        Me.Top = Application.Top + TopOffset
        Me.Left = Application.Left + LeftOffset
    
    
    End Sub
    I call this code from a public sub

    Code:
    Sub CallUserForm1()
    
    Load UserForm1
    
    
    UserForm1.Show
    
    
    End Sub
    I have several of these, all working fine.

    The modeless form is exactly the same except adding 'false' to indicate modeless
    Code:
    userform1.show false
    This causes the code in the forms window, that positions the form, to be ignored.

    is there a work around?

    Thanks in advance.

    D

  2. #2
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,990
    Post Thanks / Like
    Mentioned
    53 Post(s)
    Tagged
    6 Thread(s)

    Default Re: How to set the start position of a modeless user-form?

    It works fine for me. Is it the first time that form has been loaded and shown?

  3. #3
    Board Regular
    Join Date
    Aug 2019
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to set the start position of a modeless user-form?

    Hi, thanks for your reply.
    no, i have such down and restarted excel overnight.
    Strange

    one of these messing with it?

    Code:
    Application.EnableEvents = False
    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    Last edited by Davavo; Oct 10th, 2019 at 07:45 AM.

  4. #4
    Board Regular
    Join Date
    Aug 2019
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to set the start position of a modeless user-form?

    Doevents solved it.

    Also changed 'False' to vbmodeless but thats just to be more descriptive.

    Code:
    Sub CallUserForm9()
    
    Load UserForm9
    
    
    UserForm9.Show vbModeless
    DoEvents
    
    
    End Sub

    Thanks for your help RoryA!
    Last edited by Davavo; Oct 10th, 2019 at 08:03 AM.

  5. #5
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,990
    Post Thanks / Like
    Mentioned
    53 Post(s)
    Tagged
    6 Thread(s)

    Default Re: How to set the start position of a modeless user-form?

    Screenupdating is probably the culprit.

  6. #6
    Board Regular
    Join Date
    Aug 2019
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to set the start position of a modeless user-form?

    Quote Originally Posted by RoryA View Post
    Screenupdating is probably the culprit.
    maybe, but i checked them all.
    Last edited by Davavo; Oct 10th, 2019 at 08:49 AM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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