Find resolution of monitor that is the 2nd monitor

chuckchuckit

Well-known Member
Joined
Sep 18, 2010
Messages
541
Following code finds the resolution of your monitor (the monitor they usually call monitor 1). But if you have a 2nd or 3rd monitor that is set to a different resolution, and Excel running this code is running in monitor 2 or 3, it still returns the resolution of the main monitor #1.

How can I find the resolution of the other monitors. Or at least just find the resolution from the monitor Excel is runnning on, when it is not in the main monitor?

Should I be making the current monitor being used, active somehow?
Code:
Option Explicit
Declare Function GetSystemMetrics32 Lib "User32" _
Alias "GetSystemMetrics" (ByVal nIndex&) As Long
 
Public Sub Test()
    MsgBox GetSystemMetrics32(0) & " x " & GetSystemMetrics32(1)
End Sub
Thanks.

Chuck
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
AnAnalyst,

Looks like from those links you found, the best way to determine the resolution of any additional monitor other than the main monitor is:

Using an API call to get your monitor handle number from the screen the instance of Excel is running in. Then through that handle number you can get enough information back about the screen to calculate the resolution.

Very helpful. Thanks as I was stumped.

Chuck
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top