autosizing userform display

medic5678

Board Regular
Joined
Nov 13, 2018
Messages
67
I have a userform where I need to have the entire form visible on screen of any computer excel runs on. The size of both the form and the various controls/text in the userform need to be resized.

This is something that I of course never considered as an issue, thinking excel would do this automatically. Instead, it only shows a part of the form depending on which computer I run it on.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi Sharid ,

I have placed in Userform . Below lines are in red color.
1610296176006.png
 
Upvote 0
Try adding the word PtrSafe

Between the word Declare and Function you need to add the word PtrSafe so it look like

Private Declare PtrSafe Function

So It looks some thing like this
VBA Code:
    Private Declare PtrSafe Function IUnknown_GetWindow Lib "shlwapi" Alias "#172" (ByVal pIUnk As IUnknown, ByVal hWnd As LongPtr) As Long
    Private Declare PtrSafe Function DrawMenuBar Lib "user32.dll" (ByVal hWnd As LongPtr) As Long
    Private Declare PtrSafe Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As Long
 
Upvote 0
Hi Sharid ,

Am still getting this error. could you please let me know correct code for this.

1610372292062.png
 
Upvote 0
I'm not sure what your doing wrong. However go to my first post, on page 2 there is a downloadable file of my test form with the working code, which was updated by Jaafar. See image below, click on on Workbook Demo


Link To My First POST
Download file is on Page 2

1610390502879.png
 
Upvote 0
@Sharid @Jaafar Tribak Is this code aim is automatically reduce and increase the size of objects [txt box & labels, combos] depending on the Windows screen resolution? could you please confirm the same.

Regards,
Annapurna
 
Upvote 0
yes, There is a link to a downloadable demo above in my post I would advise that you download the demo and see for yourself

See this also

Fullscreen
1610717462072.png


Reduced
1610717517179.png


Reduced Again
1610717588938.png


Reduced in size even more
1610717679593.png
 
Upvote 0
Thank you sharid , For some reason i am getting error on my sheet and For now i have added horizontal scroll bar as work around.
I will test this code in test sheet .
 
Upvote 0

Forum statistics

Threads
1,215,134
Messages
6,123,237
Members
449,093
Latest member
Vincent Khandagale

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