Consulting

Results 1 to 7 of 7

Thread: Solved: Positioning UserForm In VBA :)

  1. #1

    Talking Solved: Positioning UserForm In VBA :)

    Can anyone please help me with a module that will allow me to position a UserForm anywhere on the screen, even if it is just in certain parts of the screen, taking into consideration the end users screen dimensions ie screen width and screen height ( Resolution IE 1024 * 768, 800 * 600, etc )

    So that I can place the UserForm say like so :
    ____________________________________
    |FORM FORM FORM |
    | | |
    | |
    |FORM FORM FORM |
    | |
    | |
    | |
    |FORM FORM FORM |
    ------------------------------------------

    Just to give you an idea

    Then from there the code that specifys them points would obviously be in a module then say I wanted to place it on the top Right I would call the function , lets say it was called FormPlacement()

    example call :

    FormPlacement(TopRight)

    Any help is very much appreciated ! Will be on if it is solved lol
    Victory comes to those whom believe it the most

    I hope I learn things from this site , otherwise I will be doing this --> LOL. I must admit coding / programming sometimes makes me do this -->

  2. #2
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hi there, and welcome to VBAX!

    You may want to go for a stroll through our KB.

    For the position, try Fine-Tune Userform Start Position

    And for resolution, try Screen Resolution Check / Change

    HTH,
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  3. #3
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    Quote Originally Posted by kpuls
    Hi there, and welcome to VBAX!

    You may want to go for a stroll through our KB.

    For the position, try Fine-Tune Userform Start Position

    And for resolution, try Screen Resolution Check / Change

    HTH,
    My colleague Chip Pearson has posted a UserForm positioning module here:
    http://cpearson.com/excel/FormPosition.htm
    This helps to position the form in a given position with respect to a worksheet cell, or other object on a sheet. It's handy if you have a small form that aids with user input, like a date picker. It accounts for how many commandbars are visible, where the sheet has been scrolled to, etc.

    About the screen resolution, I appreciate Jake's code which merely suggests the user might want to adjust their resolution, rather than trash the user's settings. (What if it's a vision-impaired user who needs 400*600 on their 17" screen? You screw with that and it's even worse than if you merely annoy a normal user with it.) But the best approach is for the programmer to adjust his forms so that they will work on any resolution. If it means you need a special multipage interface for small screens, well, it's extra work. But it's always harder to program an app that's easier to use.
    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com
    _______

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Top Left

    [vba]
    Option Explicit

    Private Sub UserForm_Initialize()

    Me.StartUpPosition = 0
    Me.Top = 0
    Me.Left = 0

    End Sub
    [/vba]

    Top Right

    [vba]
    Option Explicit

    Private Sub UserForm_Initialize()

    Me.StartUpPosition = 0
    Me.Top = 0
    Me.Left = Application.Left + Application.Width - Me.Width

    End Sub
    [/vba]

    Lower Left
    [vba]
    Option Explicit

    Private Sub UserForm_Initialize()

    Me.StartUpPosition = 0
    Me.Top = Application.Top + Application.Height - Me.Height
    Me.Left = 0

    End Sub
    [/vba]

    Lower Right
    [vba]
    Option Explicit

    Private Sub UserForm_Initialize()

    Me.StartUpPosition = 0
    Me.Top = Application.Top + Application.Height - Me.Height
    Me.Left = Application.Left + Application.Width - Me.Width

    End Sub
    [/vba]

  5. #5
    Thank you all so very much ! This forum whups A$$ I really appreicate all the help you have all given me !!

    There is a god

    All in a days hard work LOL
    Victory comes to those whom believe it the most

    I hope I learn things from this site , otherwise I will be doing this --> LOL. I must admit coding / programming sometimes makes me do this -->

  6. #6
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Hi Gecko,

    just dont forget to mark it solved by checking "Thread Tools" and "Mark it solved".
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  7. #7

    Unhappy

    If I do not login it , it shows me thread tools and only gives me the options to print it off or email it. So I logged in and now it doesnt even give me thread options from what I can see

    nm After I posted that last message it gave me the option
    Victory comes to those whom believe it the most

    I hope I learn things from this site , otherwise I will be doing this --> LOL. I must admit coding / programming sometimes makes me do this -->

Posting Permissions

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