Excel Font Size variations in List Box - excel

My code populates an Excel Form by building various labels and listbox controls into a Frame.
It positions the controls at run time depending on the data to display.
This works fine most times but sometimes a list box font appears larger, cutting off some of the text.
Various things, back colour, frame height, list height can all have an effect on the size but I cannot find a reliable pattern.
It does not help that Excel will report it is the font size set, even though it's not that size
I'm hoping some can help me cannot detect when this happens and that lead to a fix. I have tried for several years without success.

Related

Why does Excel 2010 VBA userform textbox font changes depending on size of frame?

I have a userform with several frames, labels, and textboxes, all set to a default font of Calibri Regular size 10. I noticed the font in one textbox was different than the rest; a bit slimmer, a hair shorter and more condensed than the default. I tried adjusting the font in design and runtime, messing with the font of the frame, and replacing the textbox with a new one, but nothing seems to correct the font.
Then, by accident, I moved the textbox position up a bit and the font automagically corrected itself. Weird. I've since been playing around with the textbox position and frame size. This is what I've observed:
1) The font size is dependent on the relative position within the frame; the textbox needs to be entirely in the top 50% of the frame height, and adjusting the textbox position OR frame height affects the font.
2) This issue applies to more than one frame on this userform.
3) This issue applies to labels as well as textboxes.
4) This issue is inconsistent and does NOT apply to all textboxes and labels; it's just the textboxes affected in the first frame, just the labels in a second frame, and there is no font issue in a third frame.
I've gone over the properties in all frames, labels, and textboxes in design mode and nothing stands out. All of these controls have the same font set. Has anyone ever encountered this issue before? Is this a known bug?
Same as #SquirrelBait - I too have found that the display size of the font changes in appearance depending on where it is positioned on my UserForm (created at Design time - Excel 2016). This occurred within a Multipage, but may not be relevant.
Although I don't have a solution, I may have a possible work around:
The issue only seems to occur where the Height of the Form Control (Label, TextBox, ComboBox) isn't an integer value. I auto sized some of my Controls so they were given Heights of 14.25, 28.5, 20.25 etc. I've increased all the Heights to integer values. Now the issue appears to be resolved.
I also had success changing my textbox heights from 17.5 to 18. In my case I also had them slightly overlapping (to create a table effect), which despite them being 18 font, still caused them to have a slightly larger text size. After I changed it so that the bottom of one is the top of another, everything seems to be working fine now.

Auto fit a non activex userform shapes and boxes to different screen sizes?

Challenge
Userform pictures/shapes and textboxes does not fit to different screen sizes.
I have different users with different desktop/laptop screen sizes
Misconception
I don't want to fit userform itself, I just want to fit objects(combobox/pictures) instead.
What I have tried
I tried to convert it to an active x form (to fix the shapes regardless of the screen size) instead but it would take a long time to rename shapes and re-write the code. (Not time efficent)
I tried to fix the width, top, height, disable/enable auto fit for all objects as well as userform, but still don't fit.
I tried to recognize the screen size and then fit objects, not time efficient
I need to fit shapes inside a non active x userform to fit all screen sizes, any ideas?
It worked only when I converted the USERFORM (Code & Design) to ActiveX Form (Worksheet).
Only thing to change from (ME.Object Name) to (Thisworkbook.worksheets("Name").ObjectName)
It took some time but worked finally.

Excel resizing buttons and fonts when display scale is not 100%

I have a sheet with VB buttons (using Form controls or ActiveX controls makes no difference).
When the display scale in windows is not 100%, after a button is down it resizes to something not the same size, as shown below (Export Forecast Data... button). When a different button is clicked, it pops back to normal size and the new button then gets this effect.
What you see below is 125%, but the bigger the scale, the worse it gets. In addition, as you can see, it is changing font sizes too.
If I save then reload, all buttons pressed end up resized to the smaller size they were after being clicked and do so badly, as third screenshot.
I have tried on many computers and they all have the same fault.
These have been Excel Office 365/2016.
Any ideas how to fix this? Also, I believe this may be linked to not just a scaling, but having two displays, one at 100% and the other at a different scale.
The effect of the resize after saving

Avoid distortion and wrong scaling of shapes and objects when printing Excel worksheets

Excel distorts shapes ans objects when printing.
A spreadsheet with several objects (Active-X-Radio Buttons and other) and programatically created shapes (Lines, arrows and rectangles as seen above the word 'System') should be printed as such:
Sometimes however, assumingly when the memory is low, excel distorts the layer holding all graphical objects.
In the printout these objects are completely out of size:
The bug occurs randomly and independent of the way, the sheet is printed. Either programatically saved as PDF or manually printed using the print dialog.
Yes, unbelievable, the zoom level of the active window is responsible for this behaviour.
Put Zoom of the excel page at 100% and the pictures are wrong and distorted. Put 99% and it's perfect. It sounds crazy but it works.

IBM Cognos Cross Tab alignment

I have placed two crosstabs one below another. But They are not getting aligned. How to align the two cross tabs such that corresponding columns align perfectly.
The quick and dirty way is to use fixed widths on all cells.
This will work fine for PDF, but will not work for HTML if:
You're using a modern browser (IE9+, FF/Chrome from last 5 years)
The total width exceeds screen size
There is no total width set on the crosstab itself
It will then ignore the cell widths and try to force everything to the screen width, thus the crosstabs will not align again.
I wrote some JavaScript awhile back which will combine two tables into one so fixed width is not needed. The full blog post is here. This will only affect HTML outputs, so for PDF I created a second page and just conditionally rendered one depending on user selection.
Fixed width is the only viable solution )
But you can use Report Classes to have a single “width” definition and apply it everywhere. It actually makes your reports look way neater.
Use Blocks in the cross tab cells, you will need to unlock the report first to do this
Set the block size to be the same on both cross tabs and then select content is clipped (Size and overflow property of the block)
This will work for both html and pdf output
I was able to do this by doing the following:
Set the Size & Overflow > Width of BOTH crosstabs to the same width in pixels.
Unlock the report, select the crosstab Text items in BOTH crosstabs and set them all to the same width (or individual columns to the same width if needed).
With the report still unlocked, select the text items in the crosstab 'Rows' and set those to the same width.
It's not pretty, but nothing in Cognos ever is.

Resources