Results 1 to 11 of 11

Thread: [RESOLVED] Maximized Forms

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    Resolved [RESOLVED] Maximized Forms

    How can you make a form maximized in vba. the other vb languages give you a property but vba doesn't, does anyone have code for this. cheers.

  2. #2
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    269

    Re: Maximized Forms

    WindowState property is the one you're looking for.
    Value 0 - Normal
    Value 1 - Minimized
    Value 2 - Maximized

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Maximized Forms

    VBA question moved to Office Development

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    Re: Maximized Forms

    I am using VBA not VB6 can you still help plz. In VBA it dont have a Windows State Property

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Maximized Forms

    you can use API:

    VB Code:
    1. Private Declare Function ShowWindow Lib "user32" ( _
    2.                 ByVal hwnd As Long, _
    3.                 ByVal nCmdShow As Long) As Long
    4.                
    5. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    6.                 ByVal lpClassName As String, _
    7.                 ByVal lpWindowName As String) As Long
    8.  
    9. Private Const SW_MAXIMIZE = 3
    10.  
    11. Private Sub UserForm_Click()
    12.     ShowWindow FindWindow(vbNullString, Me.Caption), SW_MAXIMIZE
    13. End Sub

    Unfortunately that goes over the taskbar as well (well for me anyway)

  6. #6
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Maximized Forms

    That's because in VBA Userforms are more like dialog boxes than actual windows. If you want to maximize it, you need to set the width and height properties to the size of the screen, or use the API.

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    Re: Maximized Forms

    I tried the code bush mobile but it didn't maximize the form. i want it so you cannot move the form around with a maximized screen

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

    Re: Maximized Forms

    Showwindow will not work as the controlbox doesnot have the maximize option. Basically its disabled. You need to use the SetWindowPos API and adjust the forms properties so its fullscreen. The otehr part is using APIs to get the screen size as there is no screen object in vba like there is in vb6.
    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

  9. #9
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Maximized Forms

    What about DoCmd.Maximize in the form Open event?
    Tengo mas preguntas que contestas

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

    Re: Maximized Forms

    No can DoCmd in Excel. If hes using Access then yes.
    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

  11. #11
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Maximized Forms

    Ah. Didn't know that, never used Excel forms.
    Tengo mas preguntas que contestas

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