PDA

View Full Version : VBA get screen resolution for multiple monitors



vanquish
01-24-2015, 07:55 AM
I need to get the screen resolution for multiple monitors. This is what I have for 1 monitor, but I'm not sure how I can do this for multiple monitors. I'm using access 2002


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

Public Function ScreenRes() As String
Dim monitor1Width As Long, monitor1Height As Long, noOfMonitors As Integer
monitor1Width = GetSystemMetrics32(0) ' Monitor1 Height
monitor1Height = GetSystemMetrics32(1) ' height in points


monitor1 = monitor1Width & "x" & monitor1Height

'get number of monitors
noOfMonitors = GetSystemMetrics32(80)


ScreenRes = monitor1




I know I could always use GetSystemMetrics32(78) and GetSystemMetrics32(79) to get the resolution of a virtual monitor, but that if there are more than 2 monitors?