+ Reply to Thread
Results 1 to 13 of 13

Position a User Form on the Screen

  1. #1
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,919

    Position a User Form on the Screen

    Every article I've found says that this should work:
    Please Login or Register  to view this content.
    The form shows up on the top left of the screen regardless of whatever number I use for .Top and .Left.

    In the attached, click on any of the plus signs on in columns C or D.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Position a User Form on the Screen

    http://www.cpearson.com/Excel/FormPosition.htm
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,919

    Re: Position a User Form on the Screen

    I get the error message: Compile error" User-defined type not defined on
    Dim PS as Position.

    Also I don't see where cstFvpauto an cstFhpAuto are defines and where the Function PositionForm is defined.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,919

    Re: Position a User Form on the Screen

    I see it now. Now I need to define it relative to a fixed cell.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,919

    Re: Position a User Form on the Screen

    Now I want the form to come up so that the top is on the target row and left is on Column M.

    How would I modify this code?
    Please Login or Register  to view this content.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Position a User Form on the Screen

    Sorry, I don't think I've ever used the code. But if Chip Pearson did it, you know it's golden.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Position a User Form on the Screen

    Try this modification
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,919

    Re: Position a User Form on the Screen

    Chip's page is one of my go to resources for things Excel. Thanks for the tip Andy, but it did not seem to help.

    I decided to strip away everything else and create a workbook with only the form and the code. Horizontally, it seems to work. However, I noticed the following on the vertical position. If I expand the formula bar, the form shows up three rows below the selected cell. If I collapse the formula bar, the form shows up 4 rows below the selected cell. Similarly, it changes vertical position relative to the cell if I expand or collapse the ribbon. It ALWAYS appears in the same vertical position on the screen or at least as far as these old eyes can recon it.

    Select a cell and click the button.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,901

    Re: Position a User Form on the Screen

    That code dates back to 2002 and a lot of it uses the commandbars to calculate positions, as well as assuming (as noted in the comments) that the formula bar is the same height as the main menu bar. Obviously, post 2003 much of that is fallible!

  10. #10
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,919

    Re: Position a User Form on the Screen

    For practical purposes, it comes out close enough and I can live with it. However, it does seem to be a lot more complicated than it has to be. Too bad we don't have something like "The screen begins at 0, 0 but the display begins at X, Y.

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,901

    Re: Position a User Form on the Screen

    There were much simpler ways in 2003 and earlier. My preference was to create a 0x0 chart, activate it to get the chart window co-ordinates and then delete it. You could then position the userform using those coordinates. Unfortunately, the chart window no longer exists, so that approach is, so to speak, out the window.

  12. #12
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,919

    Re: Position a User Form on the Screen

    It makes you wonder why everything else is relative to the grid except user forms.

  13. #13
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,901

    Re: Position a User Form on the Screen

    Userforms aren't locked to the grid in any way, or even to the application window.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. User Form Startup Position
    By ldoodle in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 07-11-2018, 06:25 AM
  2. Getting Splash Screen close with Timer then have User Form Appear
    By Hammy1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-10-2013, 02:53 PM
  3. Start Up position of User Form
    By Shazz in forum Excel General
    Replies: 3
    Last Post: 03-07-2012, 12:54 PM
  4. Set Vertical Scrollbar Position In User Form Listbox
    By Spencer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2011, 11:27 AM
  5. User Form Trails across monitor screen...
    By Stu M in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2009, 10:46 AM
  6. prevent user moving form on screen
    By memphis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2007, 05:23 PM
  7. Position Form on screen v Window Zoom !
    By RAFAAJ2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2005, 05:05 AM

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