View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default 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?