VBA - Userform & Image size issue

Nikolis

New Member
Joined
Sep 12, 2022
Messages
27
Office Version
  1. 2007
Platform
  1. Windows
Hello everybody,

I have a userform, for which I have specified the (Height = 720) & (Width = 1280) properties from the Properties panel.
And I have made a Jpeg in Photoshop which is intended as a sidebar menu background in my userform and it's (Height = 720) and (Width = 190)

Now, one would have expected that the sidebar graphic would be covering the height of the userform all the way vertically (since they both have height = 720), yet when the userform loads there is blank space in it under the graphic and, thus, a vertical scroll bar is used. A horizontal scroll bar is also needed and the blank spaces are about 1/3 of the set userform face. Those blank spaces are white, while my userform's background is set to a light blue version.

Why is this happening, can somebody explain what I'm missing here ? Many thanks in advance !
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi there

Have you maybe tried to set the userform pic property to zoom? Not sure if this will fix your problem... Also is there any reason for the specific height and width...

MREXCEL.png
 
Upvote 0
Thank you Jimmypop for your attention and feedback.
I changed the pic property to zoom and it did ;
- solve one of the issues (no margin left after the bottom of the pic),
- limit the other one (a small white margin to the right side of the userform),
- create a new one, as the sidebar pic is now somewhat (yet notably) pixelized. I mean it doesn't take an experience eye to notice that the lower right corner is "broken".

Any further ideas ?
 
Upvote 0
Will investigate... could you maybe provide us a screenshot of what it is like currently?
 
Upvote 0
Sure ... the 2 jpegs are the initial and the "after zoom" state of the userform.
Once again, many thanks !
 

Attachments

  • After Zoom.jpg
    After Zoom.jpg
    185.3 KB · Views: 60
  • Initially.jpg
    Initially.jpg
    202.8 KB · Views: 62
Upvote 0
1. Userform.Height is not the same as Userform.InsideHeight (should be read-only)
2. Userform dimensions are in points, not pixels.
3. PointsperPixel = 72/Display DPI
A regular 1920x1080 monitor is usually 96 DPI. Not sure if display scaling would change things.
Your userform should be more like 960 pixels (including titlebar) in height, while image is 720, which causes stretching.
 
Upvote 0
Solution
Gokhan thank you for your feedback and attention ! Your suggestion did solve the problem, as the conversion formula you indicated leads to a 960x540 (points) userform (equal to 1280x720 pixels). It seems to fit the image perfectly well and (appearance-wise) is what I was looking for in the first place.

Also, many thanks for the .InsideHeight pass - new as I am I didn't even know this property existed. So, typically the image doesn't fit 100%, but some ... 99% also does the job for me.

Not to forget, Jimmypop thank you, too !
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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