Results 1 to 8 of 8

Thread: Resize UserForm

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Red face Resize UserForm

    I have a userform that gathers quite a bit of info. The majority of the users will have their res set high enough to display the whole form so that I don't have to make it smaller and force them to scroll around to get to the various fields. However, some of them have really low res which makes the userform so big they can't even see the scroll bars. Is there a way to tell a userform to resize based on res? Or some other method that would serve to keep the form whole for the majority but visible for the rest?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Resize UserForm

    You could check the resolution and if its low then you could resize it down but then you would have to resize all controls
    so they will be viewable.

    Which Office App is this in, Excel?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Re: Resize UserForm

    This is in Word.

    I'm guessing then that I would also need to reset the top & left position if I resize each control?

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Re: Resize UserForm

    I do still need help, but I'm not sure that I want to go the route of resizing the form. Right now it's just the minimum size for the users to be able to see their selections. If the res is decreased and it looks bigger, so will the text - so making the controls smaller seems like it would prevent them from seeing their input. What I really want to do is make the viewing area smaller (preferably on a res dependent basis) so that everything is still the same size, but only a portion of it is displayed with scroll bars to let the user see the rest. As it stands, in low res only a portion is shown, but it takes up the whole screen with the scroll bars pushed off the edges of the screen.

    I am avoiding going the route of a tabbed form because these users react to such interfaces as though it presents more work and confusion.

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Re: Resize UserForm

    So what is the code for determining the resolution so that I can resize accordingly?

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Resize UserForm

    VB Code:
    1. Msgbox CStr(Screen.Width / Screen.TwipsPerPixelX) & "x" & CStr(Screen.Height / Screen.TwipsPerPixelY)

    Found this in another post..aparently it will give the screen resolution

  7. #7
    Lively Member JustinLabenne's Avatar
    Join Date
    Jul 2005
    Location
    Ohio
    Posts
    64

    Re: Resize UserForm

    Jumping in late:

    Resizable userform
    http://www.andypope.info/vba/resizeform.htm


    or even size the userform to the window, but some controls may be hidden
    VB Code:
    1. With Me
    2.         .Top = Application.Top
    3.         .Left = Application.Left
    4.         .Height = Application.Height
    5.         .Width = Application.Width
    6.     End With
    7.  
    8.     With Application
    9.         .WindowState = xlMinimized
    10.         .WindowState = xlMaximized
    11.     End With

    This ensures that the form is sized according to Excels Application Window.

    Best to design any forms in the lowest resolution possible, or propmt users to chage res if it doesn't match up with what you designed for

    Example here
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=32
    Justin Labenne
    www.jlxl.net

  8. #8

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Re: Resize UserForm

    These look great, thank you. I will try them out and respond at that time.

Posting Permissions

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



Click Here to Expand Forum to Full Width