Textbox not displaying all text

mcomp72

Active Member
Joined
Aug 14, 2016
Messages
275
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2011
Platform
  1. Windows
  2. MacOS
My code creates a textbox on some worksheets in the Worksheet_SelectionChange under certain conditions. Here is a snipped of the relevant code. (I haven't included the entire sub because it is quite long.)

VBA Code:
Set TB = ThisWorkbook.Sheets("Page 1").Shapes.AddTextbox(msoTextOrientationHorizontal, LeftPosition, TopPosition, 2, 2)

TB.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
TB.TextFrame2.WordWrap = False

TB.TextFrame.Characters.Text = StringVar

It works just as it should most of the time, but I've noticed at certain zoom levels of the sheet, if there is more than 1 "line" that appears in the text box (sometimes I go to a new line in the string it is displaying using vbnewline), the last line of text won't be displayed. It works fine at 100% zoom, and also at 80% zoom, but I've noticed at 90% it won't display the last line of the textbox. The height of the textbox looks the way it should, but in the space where the last line should be, there is nothing. If I change the zoom, it looks correct.

I assume this is a bug in Excel, but I'm wondering if anyone knows of a work-around, via VBA, to make all the text display as it should at ALL zoom levels?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,214,428
Messages
6,119,420
Members
448,895
Latest member
omarahmed1

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