Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA for shrinking the font in PowerPoint when text overflows

Tags:

powerpoint

vba

I'm trying to figure out a macros for PowerPoint files that I export after language conversion through a CAT tool. In some of the language pairs the translated content will not fit into the source file text boxes due to the differences in the language lengths.

Therefore, the translated and exported PowerPoint files contain multiple shapes/text boxes that have some content outside of the visible areas of such shapes. I was wondering what is way to get the newly exported textual content within all shapes/text boxes in the exported PPTs files shrunk globally throughout the file to fit the original sizes of those shapes - only for those shapes when a content overflow occurs.

All I really need is a macros with IF text height/length is more than shape height/length THEN lower font size by one until text dimensions = shape dimensions. I am working in MS Office 15.

Thank you for your input!

like image 618
Ilia Shifrin Avatar asked Oct 16 '25 16:10

Ilia Shifrin


1 Answers

Could you use the AutoSize property of the shape's TextRange and leave PowerPoint to automatically shrink the text based on the content because the fit will depend in the font face, size and style properties? You can do this with the following property:

oShp.TextFrame2.AutoSize = msoAutoSizeTextToFitShape
like image 117
Jamie Garroch - MVP Avatar answered Oct 18 '25 12:10

Jamie Garroch - MVP