Determine the screen size

 1999-07-23    Application    0    63

With the macro below you can return the screen size with the function GetSystemMetrics32.

Declare Function GetSystemMetrics32 Lib "User32" _
    Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

Sub DisplayMonitorInfo()
Dim w As Long, h As Long
    w = GetSystemMetrics32(0) ' width in points
    h = GetSystemMetrics32(1) ' height in points
    MsgBox Format(w, "#,##0") & " x " & Format(h, "#,##0"), _
        vbInformation, "Monitor Size (width x height)"
End Sub


Leave a comment:

Your comment will only be published after it has been moderated and found spam free.
Your e-mail address will only be used to display your Gravatar.