ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Screen Width & Height (https://www.excelbanter.com/excel-discussion-misc-queries/231679-screen-width-height.html)

leerem

Screen Width & Height
 
How can I increase the size of the form to the screen size.

I used the following but this produced an error. Variable Not defined


Sub Userform Initialize()
with Userform1
.Width=Screen.Width
.Height=Screen.Height
End With
End Sub

How can I increase the size of the userform to the screen size as this form
will be used on multiple screens of different sizes.

Regards
Lee

leerem

Screen Width & Height
 
Solved it by writing a few functions

Public Declare Function GetSystemMetrics Lib "User32" _
(ByVal nlndex As Long) As Long

Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1

Public Function ScreenHeight() As Long

ScreenHeight = GetSystemMetrics(SM_CYSCREEN)

End Function
Public Function ScreenWidth() As Long

ScreenWidth = GetSystemMetrics(SM_CXSCREEN)

End Function

Thanks anyway to anyone who tried to assist


"leerem" wrote:

How can I increase the size of the form to the screen size.

I used the following but this produced an error. Variable Not defined


Sub Userform Initialize()
with Userform1
.Width=Screen.Width
.Height=Screen.Height
End With
End Sub

How can I increase the size of the userform to the screen size as this form
will be used on multiple screens of different sizes.

Regards
Lee



All times are GMT +1. The time now is 07:00 PM.

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