Results 1 to 11 of 11

Thread: Position modeless userform to top right of Activewindow

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,888
    Location

    Position modeless userform to top right of Activewindow

    Working on a 'Wizard' form (below is just some test code as a proof of concept)

    I'd like the modeless UF to align top right of the active pane, but can't get the .Top's and .Left's and .Width's to work out reliably in the UserForm_Activate

    The screen shot show what I'm trying to achieve (it was manually positioned since I can't get the code the right)

    I'd like to set the height to the same as the ActiveWindow also


    Option ExplicitPrivate Sub CommandButton1_Click()
        ActiveSheet.Range("A1").Value = Format(Now, "long date") & " - " & Format(Now, "long time")
    End Sub
    Private Sub CommandButton2_Click()
        Load ufData
        ufData.Show (vbModal)
    End Sub
    Private Sub CommandButton3_Click()
        ActiveSheet.Range("A2").Value = 123
    End Sub
    Private Sub CommandButton4_Click()
        Me.Hide
        Unload Me
    End Sub
    Private Sub UserForm_Activate()
        Me.StartUpPosition = 0
        Me.Top = -Application.Top - ActiveWindow.Top
        Me.Left = -ActiveWindow.Left + ActiveWindow.Width - Me.Width
    End Sub

    Paul
    Attached Images Attached Images

Posting Permissions

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