|  

» Determine the screen size using VBA in Microsoft Excel

VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
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


Rate This Tip
12 34 5
Rating: 4.20     Views: 42904
No comments have been submitted.
Name
Comment Title
Comments