Find My PC Screen Resolution in Excel using VBA & Javascript

What is Display Resolution?

The number of Pixels displayed in your Monitor is called Screen Resolution.

It is represented as how many Pixels displayed in Screen height x Screen width. To get the screen height and width use these codes as per your programming language. The computer or mobile devices do not have standard screen resolutions.

It varies with every manufacturer and every computer model. So, the developers have to design their application to be compatible with the user’s device resolution limits.

Be it an application developer or a Web developer, everyone have to use any of these codes at some point of time.

1. What is my Screen Resolution? – VBA using Windows API

The VBA code below retrieves screen resolution parameters using 2 different methods, both using the Win api functions.

Note: Function used in method 2 in above example can be used in C Programming to get screen width & height. Include Windows.h and then use the function with same parameters in your C program.

2. Get Display resolution in Javascript

It is easy to get screen width and height with Javascript. You just need to use the ‘Screen’ Object as in below code sample.

The above can be tested right from your internet browser Firefox, Chrome or IE. To test it in Firefox, press Ctrl + Shift + q, then choose ‘Console’. Type this command ‘console.log (wscr);’ and press enter.

Firefox console will display the screen width.

3. Find Windows Screen Height & Width from Command Prompt

Open command prompt and type this command. Just so simplest of all.

By now you would be able to answer ‘What is Display resolution’ of your computer using the above free codes. If you require the coding in any specific programming language, please leave us a comment.