ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmatically maximize a userform (https://www.excelbanter.com/excel-programming/398541-programmatically-maximize-userform.html)

Gussie

Programmatically maximize a userform
 
I am creating a UserForm in excel but there is no way to automaticaly
maximize the form, I have created a function that resizes form to the area
used and added a maximize button but client wants it to be maximized when
opening form.

Can this be done?

Zone[_3_]

Programmatically maximize a userform
 
Private Sub Userform_Initialize()
me.width=application.width
me.height=application.height
End sub

"Gussie" wrote in message
...
I am creating a UserForm in excel but there is no way to automaticaly
maximize the form, I have created a function that resizes form to the area
used and added a maximize button but client wants it to be maximized when
opening form.

Can this be done?




Gussie

Programmatically maximize a userform
 
I tried that but it does not give me the entire area, it returns just the
active spreadsheet area. I downloaded the FormFun.xls but it just shows how
to add the maximize/minimize buttons. I usually work with Access and I use a
cmd.Maximize (or something like that)

Thanks!

"Zone" wrote:

Private Sub Userform_Initialize()
me.width=application.width
me.height=application.height
End sub

"Gussie" wrote in message
...
I am creating a UserForm in excel but there is no way to automaticaly
maximize the form, I have created a function that resizes form to the area
used and added a maximize button but client wants it to be maximized when
opening form.

Can this be done?





RB Smissaert

Programmatically maximize a userform
 
Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow _
Lib "user32" (ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long

Function GetFormHwnd(strCaption As String) As Long
If Val(Application.Version) = 9 Then
GetFormHwnd = FindWindow("ThunderDFrame", strCaption)
Else
GetFormHwnd = FindWindow("ThunderXFrame", strCaption)
End If
End Function

Private Sub UserForm_Initialize()

ShowWindow GetFormHwnd(Me.Caption), 3

End Sub


RBS


"Gussie" wrote in message
...
I am creating a UserForm in excel but there is no way to automaticaly
maximize the form, I have created a function that resizes form to the area
used and added a maximize button but client wants it to be maximized when
opening form.

Can this be done?



Steve Yandl

Programmatically maximize a userform
 
This might do the trick, assuming none of the PCs are Win98 or earlier.

___________________________________

Private Sub UserForm_Initialize()
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem In colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next

Me.Width = intHorizontal
Me.Height = intVertical

End Sub

__________________________________

Steve



"Gussie" wrote in message
...
I tried that but it does not give me the entire area, it returns just the
active spreadsheet area. I downloaded the FormFun.xls but it just shows
how
to add the maximize/minimize buttons. I usually work with Access and I use
a
cmd.Maximize (or something like that)

Thanks!

"Zone" wrote:

Private Sub Userform_Initialize()
me.width=application.width
me.height=application.height
End sub

"Gussie" wrote in message
...
I am creating a UserForm in excel but there is no way to automaticaly
maximize the form, I have created a function that resizes form to the
area
used and added a maximize button but client wants it to be maximized
when
opening form.

Can this be done?







Gussie

Programmatically maximize a userform
 
Thank you very much!

"RB Smissaert" wrote:

Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow _
Lib "user32" (ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long

Function GetFormHwnd(strCaption As String) As Long
If Val(Application.Version) = 9 Then
GetFormHwnd = FindWindow("ThunderDFrame", strCaption)
Else
GetFormHwnd = FindWindow("ThunderXFrame", strCaption)
End If
End Function

Private Sub UserForm_Initialize()

ShowWindow GetFormHwnd(Me.Caption), 3

End Sub


RBS


"Gussie" wrote in message
...
I am creating a UserForm in excel but there is no way to automaticaly
maximize the form, I have created a function that resizes form to the area
used and added a maximize button but client wants it to be maximized when
opening form.

Can this be done?





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

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