ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't get screen resolution (https://www.excelbanter.com/excel-programming/345409-cant-get-screen-resolution.html)

Stevens

Can't get screen resolution
 
The following code is not getting the screen resolution for me.

Dim lWidth As Long
Dim lHeight As Long

Private Sub CommandButton1_Click()
getScreenResolution lWidth, lHeight
MsgBox lWidth & " x " & lHeight, , "screen resolution"
End Sub

The error it is bringing up is sub or function not defined. The funny thing
is that it was working. All that is different is that I put my code into
another programmers file (we are both working on the same project - but doing
different parts)

Please if anyone can suggest the reason or another way to get the resolution
would be greatly appreciated

Steve S


--
SS

Don Guillett[_4_]

Can't get screen resolution
 
use

Declare Function GetSystemMetrics32 Lib "user32" Alias _
"GetSystemMetrics" (ByVal nIndex As Long) As Long
Sub Resolution()
x = GetSystemMetrics32(0)
y = GetSystemMetrics32(1)
MsgBox "My screen resolution is " & x & " by " & y & "."
End Sub
--
Don Guillett
SalesAid Software

"StevenS" wrote in message
...
The following code is not getting the screen resolution for me.

Dim lWidth As Long
Dim lHeight As Long

Private Sub CommandButton1_Click()
getScreenResolution lWidth, lHeight
MsgBox lWidth & " x " & lHeight, , "screen resolution"
End Sub

The error it is bringing up is sub or function not defined. The funny

thing
is that it was working. All that is different is that I put my code into
another programmers file (we are both working on the same project - but

doing
different parts)

Please if anyone can suggest the reason or another way to get the

resolution
would be greatly appreciated

Steve S


--
SS




Stevens

Can't get screen resolution
 
Thanks. That is finding it now. I am using the following code to try & scale
to the pixel size. Can you see what I'm doing wrong

Private Sub Worksheet_Activate()
GetSystemMetrics32 0, 1
'MsgBox (lWidth)
Select Case X
Case 640:
Windows(1).Zoom = 79
Case 800:
Windows(1).Zoom = 100
Case 1024:
Windows(1).Zoom = 130
Case 1152:
Windows(1).Zoom = 149
Case 1280:
Windows(1).Zoom = 161
End Select
End Sub
--
SS


"Don Guillett" wrote:

use

Declare Function GetSystemMetrics32 Lib "user32" Alias _
"GetSystemMetrics" (ByVal nIndex As Long) As Long
Sub Resolution()
x = GetSystemMetrics32(0)
y = GetSystemMetrics32(1)
MsgBox "My screen resolution is " & x & " by " & y & "."
End Sub
--
Don Guillett
SalesAid Software

"StevenS" wrote in message
...
The following code is not getting the screen resolution for me.

Dim lWidth As Long
Dim lHeight As Long

Private Sub CommandButton1_Click()
getScreenResolution lWidth, lHeight
MsgBox lWidth & " x " & lHeight, , "screen resolution"
End Sub

The error it is bringing up is sub or function not defined. The funny

thing
is that it was working. All that is different is that I put my code into
another programmers file (we are both working on the same project - but

doing
different parts)

Please if anyone can suggest the reason or another way to get the

resolution
would be greatly appreciated

Steve S


--
SS





Don Guillett[_4_]

Can't get screen resolution
 
try this neater version. The main problem was
GetSystemMetrics32 0, 1


Private Sub Worksheet_Activate()
Select Case GetSystemMetrics32(0)
Case 640: x = 79
Case 800: x = 100
Case 1024: x = 130
Case 1152: x = 149
Case 1280: x = 161
End Select
Windows(1).Zoom = x
'or
'activewindow.zoom=x
End Sub

--
Don Guillett
SalesAid Software

"StevenS" wrote in message
...
Thanks. That is finding it now. I am using the following code to try &

scale
to the pixel size. Can you see what I'm doing wrong

Private Sub Worksheet_Activate()
GetSystemMetrics32 0, 1
'MsgBox (lWidth)
Select Case X
Case 640:
Windows(1).Zoom = 79
Case 800:
Windows(1).Zoom = 100
Case 1024:
Windows(1).Zoom = 130
Case 1152:
Windows(1).Zoom = 149
Case 1280:
Windows(1).Zoom = 161
End Select
End Sub
--
SS


"Don Guillett" wrote:

use

Declare Function GetSystemMetrics32 Lib "user32" Alias _
"GetSystemMetrics" (ByVal nIndex As Long) As Long
Sub Resolution()
x = GetSystemMetrics32(0)
y = GetSystemMetrics32(1)
MsgBox "My screen resolution is " & x & " by " & y & "."
End Sub
--
Don Guillett
SalesAid Software

"StevenS" wrote in message
...
The following code is not getting the screen resolution for me.

Dim lWidth As Long
Dim lHeight As Long

Private Sub CommandButton1_Click()
getScreenResolution lWidth, lHeight
MsgBox lWidth & " x " & lHeight, , "screen resolution"
End Sub

The error it is bringing up is sub or function not defined. The funny

thing
is that it was working. All that is different is that I put my code

into
another programmers file (we are both working on the same project -

but
doing
different parts)

Please if anyone can suggest the reason or another way to get the

resolution
would be greatly appreciated

Steve S


--
SS








All times are GMT +1. The time now is 04:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com