Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help saving and resetting users screen resolution 1

Status
Not open for further replies.

akn846

Technical User
Oct 16, 2001
51
GB
Can anyone suggest any code which I could add to my Excel based application in order to save the current settings for the users screen resolution - and then during part of the application close down process set the resolution back to what it was before the user entered the application.

Many thanks

Andy
 
You could try saving the following information

Application.Height
Application.Width

You may not be able to change these settings but it might be useful.
 
You can't change the settings of these. Sorry...
 
Ratman's Muggy Monday's Special of the Day !

Return Screen Resolution:

Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type

Declare Function GetDesktopWindow Lib "User32" () As Long
Declare Function GetWindowRect Lib "User32" _
(ByVal hWnd As Long, rectangle As RECT) As Long

Sub resolution()
MsgBox GetScreenResolution
End Sub

Function GetScreenResolution() As String
Dim R As RECT
Dim hWnd As Long
Dim RetVal As Long

hWnd = GetDesktopWindow()
RetVal = GetWindowRect(hWnd, R)

GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)

End Function
 
Thanks ratman - all I need now is some code to set the resolution!
 
Just a follow up on my previous thread.....this returns the screen resolution also:


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 Thank you,
Dave Rattigan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top