How to retrieve screen size/resolution in MS Access VBA to re-size a form

后端 未结 2 1343
天命终不由人
天命终不由人 2020-12-11 08:15

I have two popup forms (parent/child) that I want to be able to automatically re-size depending on the size of the screen.

How can I retrieve the size of the screen

相关标签:
2条回答
  • 2020-12-11 08:55

    For VBA, a simpler (and therefore possibly more portable) solution might be:

    Application.UsableHeight
    Application.UsableWidth
    

    As found at Adjust userforms to fit in screen. I am using this successfully with Word 2007 VBA. In my case, Application.UsableWidth gives the actual screen width, Application.UsableHeight gives the actual screen height, minus the height of Windows' taskbar.

    0 讨论(0)
  • 2020-12-11 08:58

    For Access 2010 64 bit, you will need to add PtrSafe before Function.

    Declare Function GetSystemMetrics32 Lib "User32" _
        Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
    
    Sub ScreenRes()
    Dim w As Long, h As Long
        w = GetSystemMetrics32(0) ' width in points
        h = GetSystemMetrics32(1) ' height in points
    
    End Sub
    

    More info: http://support.microsoft.com/kb/210603

    0 讨论(0)
提交回复
热议问题