user1334858
user1334858

Reputation: 1935

How to auto size text in a TextRange in PowerPoint

I am creating a PowerPoint using C++/CLI and the .net framework. I will not know how much text will be in a text box/TextFrame. I was wondering if there is a way to auto size the text inside the text box/TextFrame so the text will fit into the size of text box I have created. The width does not change, but the height is changing on me.

I know you can set the font size by doing

TextRange->Font-> Size = 12

But is there a way to do something like

TextRange->Font-> AutoSize = true;

or

TextRange->TextExceedBoundaried = False;

Or something to that effect?

As of right now I input the text and then the text box changes size and shape. How can I get the text to change size depending on the size of the text box, not the text box change depending on the size of the text.

Upvotes: 1

Views: 3132

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

In VBA, assuming a reference to the shape in oSh:

With oSh.TextFrame2
    .AutoSize = msoAutoSizeTextToFitShape
End With

[and added as an afterthought]

msoAutoSizeTextToFitShape is a constant, VB/VBA Long = 2

That'd be an Integer in .NET, I believe.

Upvotes: 1

Related Questions