Resize userform to fill the screen and resize the controls

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Resize userform to fill the screen and resize the controls

Post by YasserKhalil »

Hello everyone

I am trying to resize the userform so as to fit the screen and at the same time to resize the controls on it .. I have found classes modules which I think is related to the subject but I don't know why it doesn't work properly
I have attached the sample file with my attempts ..
Thanks advanced for help
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Resize userform to fill the screen and resize the contro

Post by HansV »

Doesn't the site where you found the class modules provide an example?
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Resize userform to fill the screen and resize the contro

Post by YasserKhalil »

In fact this was a code that I kept in a text file and I don't remember the source ..

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Resize userform to fill the screen and resize the contro

Post by HansV »

OK, I found the source - it's from Andy Pope: Anchor controls and resizing userform

Please download the sample workbook from that page and use that - your workbook is missing some essential parts of the code.
Best wishes,
Hans

User avatar
Nick Vittum
4StarLounger
Posts: 475
Joined: 21 Feb 2020, 21:27
Location: Vermont (USA)

Re: Resize userform to fill the screen and resize the contro

Post by Nick Vittum »

I'm glad to see this, for future reference.
—Nick

I’m only an egg (but hard-boiled)

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Resize userform to fill the screen and resize the contro

Post by YasserKhalil »

I don't know what's missing.. I have two class modules and standard module with some public variables (enumAnchorStyles)
I think I have to deal with each control on the userform ..
My final target is fit the userform to the whole screen and at the same time to resize the controls according to the screen resolution.

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Resize userform to fill the screen and resize the contro

Post by HansV »

1) Add the following line at the end of UserForm_Initialize:

Code: Select all

    UserForm_Resize
2) Add blocks similar to

Code: Select all

        With .Anchor("Frame1")
            .anchorStyle = enumAnchorStyleLeft Or enumAnchorStyleRight Or enumAnchorStyleBottom Or enumAnchorStyleTop
            .minimumHeight = 120
        End With
for each control that you want to resize. It's up to you to figure out which settings you need for each control.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Resize userform to fill the screen and resize the contro

Post by YasserKhalil »

Thanks a lot, Mr. Hans
I will try to adjust the rest of the controls.