vba to find Screen size in 64bit environment

Giordano Bruno

Well-known Member
Joined
Jan 7, 2007
Messages
1,352
Hi all. Can someone show me how to get the screen metrics when using a 64bit version of Excel i.e. where do I use "long" and where do I use
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If you're using the GetSystemMetrics API call, none of the variables change type. You just need to add the PtrSafe attribute.
 
Upvote 0
Like this?
Code:
Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal Index As Long) As Long
Private Const SM_CXSCREEN As Long = 0
Private Const SM_CYSCREEN As Long = 1
Public Sub ShowScreenDimensions()
   Dim X As Long
   Dim Y As Long
   X = GetSystemMetrics(SM_CXSCREEN)
   Y = GetSystemMetrics(SM_CYSCREEN)
End Sub
 
Last edited by a moderator:
Upvote 0
Yes, exactly like that, but with code tags of course. :)
 
Last edited:
Upvote 0
Rory, you are a living national treasure. Many many thanks for your help it is much appreciated. And I felt bad about the missing code tags, but obviously not bad enough to do anything about it. I will try to do better next time.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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