GemBox Support Forum

Shrink Text on Overflow

If I have a textbox in a pptx that has the ‘shrink text on overflow’ setting set to true, and I load more text into the box that fits (using a .Replace, .TextLoad etc) and using sh.Text.Format.AutoFit = TextAutoFit.ShrinkTextOnOverflow; after changing text doesn’t help.

VBA has a similar issue when manipulating text, so I use the following, but I can’t find the equivalent to the BoundHeight in the object model

h_max = ob.Height - ob.TextFrame.MarginTop - ob.TextFrame.MarginBottom
While (ob.TextFrame.TextRange.BoundHeight - h_max) > 6 And ob.TextFrame.TextRange.Font.Size > 4
    ob.TextFrame.TextRange.Font.Size = Round(ob.TextFrame.TextRange.Font.Size * 0.9, 0)