Click to See Complete Forum and Search --> : VBA, screen width/height?
coox
Nov 21st, 1999, 08:45 PM
Anyone know how I can find the screen height and width in VBA? I want to make a form fill the screen.
ShadowCrawler
Nov 21st, 1999, 09:18 PM
To find the screen's height in twips:
Screen.Width
Screen.Height
To find it in pixels:
Screen.Width / Screen.TwipsPerPixelX
Screen.Height / Screen.TwipsPerPixelY
------------------
(¯`·.¸¸.·´¯`·->ShadowCrawler<-·´¯`·.¸¸.·´¯)
Teenage Programmer
Visual Basic, HTML, C++, JavaScript
http://welcome.to/X12Tech
Email: craigkovatch@compuserve.com
ICQ#: 9872708 (http://wwp.mirabilis.com/9872708)
coox
Nov 21st, 1999, 09:37 PM
Sorry ShadowCrawler, I'm talking VBA here, not the real thing. It doesn't recognise the Screen object. Any thoughts? (I'm sure you all have many thoughts, most of them unprintable, but hey...)
I'm sure there has to be a better way but this works for me (in word 2000).
Option Explicit
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub ScreenSize()
Dim ScreenRect As RECT
Dim ret As Long
ret = GetClientRect(CLng(GetDesktopWindow()), ScreenRect)
MsgBox "Width: " & ScreenRect.Right - ScreenRect.Left
MsgBox "Height: " & ScreenRect.Bottom - ScreenRect.Top
End Sub
Private Sub Document_New()
ScreenSize
End Sub
------------------
Vincent van den Braken
EMail: azzmodan@azzmodan.demon.nl
ICQ: 15440110 (http://www.icq.com/15440110)
Homepage: http://www.azzmodan.demon.nl
coox
Nov 22nd, 1999, 04:05 PM
Thanks Azzmodan, that works great - you're a star
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.