Screen Width & Height

L

leerem

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
 
L

leerem

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
 
L

leerem

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top