Option Explicit


Private Declare Function GetSystemMetrics _
Lib "user32.dll" ( _
ByVal nIndex As Long) _
As Long
'The GetSystemMetrics function retrieves various system metrics and system
'configuration settings.System metrics are the dimensions (widths and heights)
'of Windows display elements. All dimensions retrieved by GetSystemMetrics are in pixels.

Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1

Sub Get_Change_ScreenSize()
Dim x As Long, y As Long, sYourMessage, iConfirm As Integer

x = GetSystemMetrics(SM_CXSCREEN)
y = GetSystemMetrics(SM_CYSCREEN)

sYourMessage = "Your current screen size is " & x & " X " & y & vbCrLf
sYourMessage = sYourMessage & "Would you like to change the resolution?"

iConfirm = MsgBox(sYourMessage, vbExclamation + vbYesNo, "Screen Resolution")
If iConfirm = vbYes Then
'Change screen settings
Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
End If

End Sub