Full size userform

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
I have this code that makes my userform full page, the problem is that any other objects on the userform do not do the same, like multipages, buttons, images textboxes, etc.
Is there was to do it so that everything will expand. I was testing it on this form, see the attached picture

VBA Code:
Private Sub Userform_Activate()
With Application
   Me.Top = .Top
    Me.Left = .Left
    Me.Height = .Height
    Me.Width = .Width
End With
End Sub

The multipage was the original size of the userform, the above code expanded the form, but everything else stayed the size it was designed. Is there a way to do it so everything changes size

Thanks
 

Attachments

  • CaptureForm.JPG
    CaptureForm.JPG
    42.8 KB · Views: 14

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Not sure why, see the download link for a copy of my test

Also some of the code showed in red as seen in image see attached, out of my depth to advise you why
Download File from Here

Also the command button is NOW opening the form in Full mode and not in normal size as it was doing and states on the sheet
 

Attachments

  • Screenshot004.jpg
    Screenshot004.jpg
    243.3 KB · Views: 10
Upvote 0
@Sharid

If you don't want the userform to be shown in full size, just comment out the following line in the MakeFormResizeable routine.
VBA Code:
 PostMessage hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0

The lines in the code that you highlighted in yellow are in red because the VBA7 compiler doesn't recognize them... You can safely ignore them and leave them intact. they won't affect the code.
 
Upvote 0
I can't resize the userform itself!!

Strange!

Try adding a Debug.Print statement at the end of the CreateMenu routine and let me know the output you get in the immediate window :

VBA Code:
Private Sub CreateMenu()
    Call WindowFromAccessibleObject(Ufrm, hwnd)
    lStyle = GetWindowLong(hwnd, GWL_STYLE)
    lStyle = lStyle Or WS_SYSMENU Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_THICKFRAME
    SetWindowLong hwnd, GWL_STYLE, lStyle
    DrawMenuBar hwnd
    Debug.Print hwnd  '<===================
End Sub
 
Upvote 0
In fact, try this with two Debug.Print statements ;
VBA Code:
Private Sub CreateMenu()
    Call WindowFromAccessibleObject(Ufrm, hwnd)
    lStyle = GetWindowLong(hwnd, GWL_STYLE)
    lStyle = lStyle Or WS_SYSMENU Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_THICKFRAME
    Debug.Print SetWindowLong(hwnd, GWL_STYLE, lStyle) & vbTab & "Style"  '<===================
    DrawMenuBar hwnd
    Debug.Print hwnd & vbTab & "HWND"   '<===================
End Sub
 
Upvote 0
This is what I got in immediate window
VBA Code:
1443823616  Style
132094  HWND

That output means the hwnd variable holds the correct form window handle and that the form style is changed successfully. So, I have no idea why it doesn't work for you and you can't resize the form.

Is there something about Office 365 that causes API calls to not work as expected - I don't know to be honest.
 
Upvote 0
Jaafar Tribak
Thanks for your up dates, I am happy with your code. its super.

As for Yasser -
Upload an image or a demo of your form so we can see what you mean as I can't see any faults with the code, as it works for me
 
Upvote 0

Forum statistics

Threads
1,214,374
Messages
6,119,155
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top